pidfile.h 762 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. // PID-file object
  2. //
  3. // Platform: ISO C++ 98/11 - POSIX
  4. // $Id$
  5. //
  6. // (c) __vic 2011
  7. #ifndef __VIC_POSIX_PIDFILE_H
  8. #define __VIC_POSIX_PIDFILE_H
  9. #include<__vic/defs.h>
  10. #include<exception>
  11. #include<string>
  12. namespace __vic { namespace posix {
  13. //////////////////////////////////////////////////////////////////////////////
  14. class pidfile : private non_copyable
  15. {
  16. std::string name;
  17. int fd;
  18. public:
  19. struct already_exists : public std::exception
  20. {
  21. const char *what() const noexcept;
  22. };
  23. explicit pidfile(std::string );
  24. ~pidfile();
  25. void create();
  26. void prepare_to_daemon();
  27. void rewrite_pid();
  28. };
  29. //////////////////////////////////////////////////////////////////////////////
  30. }} // namespace
  31. #endif // header guard