blob: 3c16db25519ce268cb79e2d996c7fb7340d30b26 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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
|