8 #include "wvlockfile.h"
23 return !pid || pid == getpid();
32 WvFile lock(lockname, O_WRONLY|O_CREAT|O_EXCL);
36 lock.print(
"%s\n", getpid());
56 WvString lockdir(getdirname(lockname));
58 if (access(lockdir, W_OK) < 0
59 || (!access(lockname, F_OK) && access(lockname, R_OK) < 0))
64 line =
lock.blocking_getline(-1);
68 if (pid != -1 && kill(pid, 0) < 0 && errno == ESRCH)
A WvFastString acts exactly like a WvString, but can take (const char *) strings without needing to a...
WvFile implements a stream connected to a file or Unix device.
pid_t readpid()
Returns one of three things: -1 if the lockfile exists, but is inaccessible.
bool lock()
Creates the lockfile with the current pid.
bool unlock()
Removes the lockfile if present.
bool isok()
Check to make sure no lock is established or that it's owned by us.
WvString is an implementation of a simple and efficient printable-string class.