Make WvStreams compile with gcc 4.4.
[wvstreams.git] / include / wvlockfile.h
blobc553cfdb7e1a591a475d2f347744d583b082a755
1 /* -*- Mode: C++ -*-
2 * Worldvisions Weaver Software:
3 * Copyright (C) 1997-2002 Net Integration Technologies, Inc.
5 * A simple lockfile class using WvStreams.
6 */
8 #ifndef __WVLOCKFILE_H
9 #define __WVLOCKFILE_H
11 #include "wvfile.h"
14 class WvLockFile
16 public:
17 WvLockFile(WvStringParm _lockname);
19 /** Check to make sure no lock is established or that it's owned by us. */
20 bool isok();
22 /** Creates the lockfile with the current pid. Returns success/failure. */
23 bool lock();
25 /**
26 * Removes the lockfile if present. If there's no lockfile after,
27 * returns true, otherwise false.
29 bool unlock();
31 /**
32 * Returns one of three things:
33 * -1 if the lockfile exists, but is inaccessible.
34 * 0 if there is no lockfile, or the process is not running.
35 * >0 The pid of the known-running process that owns the lock.
37 pid_t readpid();
39 protected:
40 WvString lockname;
43 #endif // __WVLOCKFILE_H