Lines Matching +full:parent +full:- +full:locked

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.
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?
148 bool locked; local
153 locked = lockfile(fd, filename, "[owner]", LOCK_EX);
154 if (!locked)
172 locked = lockfile(fd, filename, "[owner]", LOCK_UN);
173 if (!locked)
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?
199 ** 0 if not 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}
252 bool locked; local
259 long locked; local
261 locked = chklck(fd);
262 if (locked > 0)
263 fprintf(stderr, "%d: %ld: file=%s status=locked pid=%ld\n",
264 (int) pid, (long) time(NULL), filename, locked);
265 else if (0 == locked)
279 for (cnt = 0; cnt < delay - 2; cnt++)
282 locked = lockfile(fd, filename, "[client]", lt|LOCK_NB);
283 if (locked)
292 locked = lockfile(fd, filename, "[client]", lt);
293 if (!locked)
304 locked = lockfile(fd, filename, "[client]", LOCK_UN);
305 if (!locked)
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"
367 while ((ch = getopt(argc, argv, OPTIONS)) != -1)
410 fpid = -1;
420 /* give the parent the chance to set up data */