powerd++  0.4.4
Public Member Functions | Private Attributes | List of all members
sys::pid::Pidfile Class Referencefinal

A wrapper around the pidfile_* family of commands implementing the RAII pattern. More...

#include <pidfile.hpp>

Public Member Functions

 Pidfile (char const *const pfname, mode_t const mode)
 Attempts to open the pidfile. More...
 
 ~Pidfile ()
 Removes the pidfile.
 
pid_t other ()
 Returns the PID of the other process holding the lock.
 
void write ()
 Write PID to the file, should be called after daemon(). More...
 

Private Attributes

pid_t otherpid
 In case of failure to acquire the lock, the PID of the other process holding it is stored here.
 
pidfh * pfh
 Pointer to the pidfile state data structure. More...
 

Detailed Description

A wrapper around the pidfile_* family of commands implementing the RAII pattern.

Constructor & Destructor Documentation

◆ Pidfile()

sys::pid::Pidfile::Pidfile ( char const *const  pfname,
mode_t const  mode 
)
inline

Attempts to open the pidfile.

Parameters
pfname,modeArguments to pidfile_open()
Exceptions
pid_tThrows the PID of the other process already holding the requested pidfile
sys::sc_error<error>Throws with the errno of pidfile_open()

Member Function Documentation

◆ write()

void sys::pid::Pidfile::write ( )
inline

Write PID to the file, should be called after daemon().

Exceptions
sys::sc_error<error>Throws with the errno of pidfile_write()

Member Data Documentation

◆ pfh

pidfh* sys::pid::Pidfile::pfh
private

Pointer to the pidfile state data structure.

Thus is allocated by pidfile_open() and assumedly freed by pidfile_remove().


The documentation for this class was generated from the following file: