--- a/upmpd/upmpdutils.hxx
+++ b/upmpd/upmpdutils.hxx
@@ -62,4 +62,28 @@
extern std::string regsub1(const std::string& sexp, const std::string& input,
const std::string& repl);
+/// Lock/pid file class. From Recoll
+class Pidfile {
+public:
+ Pidfile(const std::string& path) : m_path(path), m_fd(-1) {}
+ ~Pidfile();
+ /// Open/create the pid file.
+ /// @return 0 if ok, > 0 for pid of existing process, -1 for other error.
+ pid_t open();
+ /// Write pid into the pid file
+ /// @return 0 ok, -1 error
+ int write_pid();
+ /// Close the pid file (unlocks)
+ int close();
+ /// Delete the pid file
+ int remove();
+ const std::string& getreason() {return m_reason;}
+private:
+ std::string m_path;
+ int m_fd;
+ std::string m_reason;
+ pid_t read_pid();
+ int flopen();
+};
+
#endif /* _UPMPDUTILS_H_X_INCLUDED_ */