Lines Matching +full:read +full:- +full:delay

12 SM_IDSTR(id, "@(#)$Id: t-lockfile.c,v 1.2 2013-11-22 20:51:50 ca Exp $")
25 ** OPENFILE -- open a file
28 ** owner -- create file?
29 ** filename -- name of file.
30 ** flags -- flags for open(2)
52 return -1;
56 ** WRBUF -- write iobuf to fd
59 ** fd -- file descriptor.
83 ** RDBUF -- read from fd
86 ** fd -- file descriptor.
87 ** xbuf -- expected content.
90 ** ==0 read was ok and content matches
103 r = read(fd, iobuf, sizeof(iobuf));
106 fprintf(stderr, "%d: %ld: owner=0, read()=fail\n",
112 fprintf(stderr, "%d: %ld: owner=0, read=%s expected=%s\n",
120 ** LOCKTESTWR -- test WR/EX file locking
123 ** owner -- create file?
124 ** filename -- name of file.
125 ** flags -- flags for open(2)
126 ** delay -- how long to keep file locked?
142 locktestwr(filename, flags, delay) in locktestwr() argument
145 int delay;
167 if (delay > 0)
168 sleep(delay);
184 fd = -1;
190 ** CHKLCK -- check whether fd is locked (only for fcntl())
193 ** owner -- create file?
194 ** filename -- name of file.
195 ** flags -- flags for open(2)
196 ** delay -- how long to keep file locked?
225 return -1L;
230 ** LOCKTESTRD -- test file locking for reading
233 ** filename -- name of file.
234 ** flags -- flags for open(2)
235 ** delay -- how long is file locked by owner?
236 ** shared -- LOCK_{EX/SH}
244 locktestrd(filename, flags, delay, shared) in locktestrd() argument
247 int delay;
279 for (cnt = 0; cnt < delay - 2; cnt++)
290 if (delay > 0)
316 fd = -1;
322 ** USAGE -- show usage
325 ** prg -- name of program
336 "-f filename use filename\n"
337 "-i do not perform I/O\n"
338 "-n do not try non-blocking locking first\n"
339 "-R only start reader process\n"
340 "-r use shared locking for reader\n"
341 "-s delay sleep delay seconds before unlocking\n"
342 "-W only start writer process\n"
357 int ch, delay, r, status, flags, shared, nb, reader, writer; local
362 delay = 5;
367 while ((ch = getopt(argc, argv, OPTIONS)) != -1)
396 delay = atoi(optarg);
410 fpid = -1;
423 r = locktestrd(filename, flags, nb ? delay : 0, shared);
428 r = locktestwr(filename, flags, delay);