8 #include "wvlockfile.h" 22 pid_t pid = readpid();
23 return !pid || pid == getpid();
32 WvFile lock(lockname, O_WRONLY|O_CREAT|O_EXCL);
36 lock.print(
"%s\n", getpid());
48 return readpid() == 0;
56 WvString lockdir(getdirname(lockname));
58 if (access(lockdir, W_OK) < 0
59 || (!access(lockname, F_OK) && access(lockname, R_OK) < 0))
63 WvFile lock(lockname, O_RDONLY);
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.
bool isok()
Check to make sure no lock is established or that it's owned by us.
char * blocking_getline(time_t wait_msec, int separator='\n', int readahead=1024)
This is a version of getline() that allows you to block for more data to arrive.
bool lock()
Creates the lockfile with the current pid.
virtual bool isok() const
return true if the stream is actually usable right now
bool unlock()
Removes the lockfile if present.
WvString is an implementation of a simple and efficient printable-string class.
pid_t readpid()
Returns one of three things: -1 if the lockfile exists, but is inaccessible.