libmoost
moost::process::pidfile Class Reference

Create a process pid file. More...

#include <pidfile.hpp>

List of all members.

Public Member Functions

 pidfile (pid_t const pid, std::string const &process_name, boost::filesystem::path const &rundir)
 Construct a pidfile object.
 pidfile (std::string const &process_name, boost::filesystem::path const &rundir)
 Construct a pidfile object.
 pidfile (pid_t const pid, boost::filesystem::path const &filepath)
 Construct a pidfile object.
 pidfile (boost::filesystem::path const &filepath)
 Construct a pidfile object.
 ~pidfile ()
 Destruct a pidfile object.
bool create () const
 Create a new pid file.
bool create (pid_t const pid)
 Create a new pid file.
bool remove () const
 Remove pid file.

Static Public Member Functions

static boost::filesystem::path get_default_rundir ()
 Get the default run directory.

Private Attributes

pid_t pid_
boost::filesystem::path filepath_

Detailed Description

Create a process pid file.

Will create the pid on construction and remove on destruction.

Definition at line 45 of file pidfile.hpp.


Constructor & Destructor Documentation

moost::process::pidfile::pidfile ( pid_t const  pid,
std::string const &  process_name,
boost::filesystem::path const &  rundir 
) [inline]

Construct a pidfile object.

Construct a pidfile object with the pid set

Exceptions:
ifit fails to create the pid file a runtime_error will be emitted.
Parameters:
thepid that will be associated with this instance
process_nameThe name of the process to associate with this pidfile
rundirThe run directory where the pid file will be created You should use get_default_rundir() unless you wish to specify a non-standard location
Warning:
This class is NOT thread safe

Definition at line 63 of file pidfile.hpp.

Here is the call graph for this function:

moost::process::pidfile::pidfile ( std::string const &  process_name,
boost::filesystem::path const &  rundir 
) [inline, explicit]

Construct a pidfile object.

Construct a pidfile object with the pid unset at this time (-1)

Parameters:
process_nameThe name of the process to associate with this pidfile
rundirThe run directory where the pid file will be created You should use get_default_rundir() unless you wish to specify a non-standard location

Definition at line 86 of file pidfile.hpp.

moost::process::pidfile::pidfile ( pid_t const  pid,
boost::filesystem::path const &  filepath 
) [inline]

Construct a pidfile object.

Construct a pidfile object with the pid set

Exceptions:
ifit fails to create the pid file a runtime_error will be emitted.
Parameters:
thepid that will be associated with this instance
filepaththe file name and path of the pidfile
Warning:
This class is NOT thread safe

Definition at line 107 of file pidfile.hpp.

Here is the call graph for this function:

moost::process::pidfile::pidfile ( boost::filesystem::path const &  filepath) [inline, explicit]

Construct a pidfile object.

Construct a pidfile object with the pid unset at this time (-1)

Parameters:
filepaththe file name and path of the pidfile

Definition at line 127 of file pidfile.hpp.

Destruct a pidfile object.

Destruct a pidfile object, removing the pid file in the process

Definition at line 140 of file pidfile.hpp.


Member Function Documentation

bool moost::process::pidfile::create ( ) const [inline]

Create a new pid file.

Using the last assigned pid, a new pid file will be created (any old one is removed first)

Exceptions:
ifthe pid has not been set a runtime_error will be emitted.

Definition at line 158 of file pidfile.hpp.

Here is the caller graph for this function:

bool moost::process::pidfile::create ( pid_t const  pid) [inline]

Create a new pid file.

Set a new pid for this instance and use it to create a new pid file

Parameters:
thepid that will be associated with this instance

Definition at line 180 of file pidfile.hpp.

Here is the call graph for this function:

static boost::filesystem::path moost::process::pidfile::get_default_rundir ( ) [inline, static]

Get the default run directory.

Get the default run directory where the pidfile should be created for this platform. You can use any directory you like but it is generally best to stick to using the default for the platform.

Definition at line 205 of file pidfile.hpp.

Here is the caller graph for this function:

bool moost::process::pidfile::remove ( ) const [inline]

Remove pid file.

Remove the pid file associated with this instance

Definition at line 192 of file pidfile.hpp.


Member Data Documentation

boost::filesystem::path moost::process::pidfile::filepath_ [private]

Definition at line 213 of file pidfile.hpp.

Definition at line 212 of file pidfile.hpp.


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