|
a/src/utils/pathut.h |
|
b/src/utils/pathut.h |
|
... |
|
... |
99 |
private:
|
99 |
private:
|
100 |
string m_dirname;
|
100 |
string m_dirname;
|
101 |
string m_reason;
|
101 |
string m_reason;
|
102 |
};
|
102 |
};
|
103 |
|
103 |
|
|
|
104 |
/// Lock/pid file class. This is quite close to the pidfile_xxx
|
|
|
105 |
/// utilities in FreeBSD with a bit more encapsulation. I'd have used
|
|
|
106 |
/// the freebsd code if it was available elsewhere
|
|
|
107 |
class Pidfile {
|
|
|
108 |
public:
|
|
|
109 |
Pidfile(const string& path) : m_path(path), m_fd(-1) {}
|
|
|
110 |
~Pidfile();
|
|
|
111 |
/// Open/create the pid file.
|
|
|
112 |
/// @return 0 if ok, > 0 for pid of existing process, -1 for other error.
|
|
|
113 |
pid_t open();
|
|
|
114 |
/// Write pid into the pid file
|
|
|
115 |
/// @return 0 ok, -1 error
|
|
|
116 |
int write_pid();
|
|
|
117 |
/// Close the pid file (unlocks)
|
|
|
118 |
int close();
|
|
|
119 |
/// Delete the pid file
|
|
|
120 |
int remove();
|
|
|
121 |
const string& getreason() {return m_reason;}
|
|
|
122 |
private:
|
|
|
123 |
string m_path;
|
|
|
124 |
int m_fd;
|
|
|
125 |
string m_reason;
|
|
|
126 |
pid_t read_pid();
|
|
|
127 |
int flopen();
|
|
|
128 |
};
|
|
|
129 |
|
104 |
#endif /* _PATHUT_H_INCLUDED_ */
|
130 |
#endif /* _PATHUT_H_INCLUDED_ */
|