diff options
Diffstat (limited to 'maildrop/filelock.h')
| -rw-r--r-- | maildrop/filelock.h | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/maildrop/filelock.h b/maildrop/filelock.h new file mode 100644 index 0000000..3c16db2 --- /dev/null +++ b/maildrop/filelock.h @@ -0,0 +1,30 @@ +#ifndef filelock_h +#define filelock_h + + +#include "exittrap.h" + +///////////////////////////////////////////////////////////////////////////// +// +// Encapsulate the flock() system call. By encapsulating the system call +// in a class, this allows automatic cleanup if, for some reason, an +// exception is thrown while a lock is being held. +// +///////////////////////////////////////////////////////////////////////////// + +class FileLock : public ExitTrap { + + void cleanup(); + void forked(); + + int fd; +public: + FileLock(); + virtual ~FileLock(); + void Lock(const char *); + void UnLock(); + +static void do_filelock(int); +} ; + +#endif |
