Kea  2.3.5-git
isc::util::PIDFile Class Reference

Class to help with processing PID files. More...

#include <pid_file.h>

Public Member Functions

 PIDFile (const std::string &filename)
 Constructor. More...
 
 ~PIDFile ()
 Destructor. More...
 
int check () const
 Read the PID in from the file and check it. More...
 
void deleteFile () const
 Delete the PID file. More...
 
std::string getFilename () const
 Returns the path to the PID file. More...
 
void write (int) const
 Write the PID to the file. More...
 
void write () const
 Get PID of the current process and write it to the file. More...
 

Detailed Description

Class to help with processing PID files.

This is a utility class to manipulate PID file. It provides functions for writing and deleting a file containing a PID as well as for extracting a PID from a file and checking if the process is still running.

Definition at line 40 of file pid_file.h.

Constructor & Destructor Documentation

◆ PIDFile()

isc::util::PIDFile::PIDFile ( const std::string &  filename)

Constructor.

Parameters
filenamePID filename.

Definition at line 18 of file pid_file.cc.

◆ ~PIDFile()

isc::util::PIDFile::~PIDFile ( )

Destructor.

Definition at line 22 of file pid_file.cc.

Member Function Documentation

◆ check()

int isc::util::PIDFile::check ( ) const

Read the PID in from the file and check it.

Read the PID in from the file then use it to see if a process with that PID exists. If the file doesn't exist treat it as the process not being there. If the file exists but can't be read or it doesn't have the proper format treat it as the process existing.

Returns
returns the PID if it is in, 0 otherwise.
Exceptions
throwsPIDCantReadPID if it was able to open the file but was unable to read the PID from it.

Definition at line 26 of file pid_file.cc.

References isc_throw.

Referenced by isc::lfc::LFCController::launch(), and isc::dhcp::Memfile_LeaseMgr::persistLeases().

◆ deleteFile()

void isc::util::PIDFile::deleteFile ( ) const

Delete the PID file.

Exceptions
throwsPIDFileError if it can't delete the PID file

Definition at line 84 of file pid_file.cc.

References isc_throw.

Referenced by isc::lfc::LFCController::launch().

◆ getFilename()

std::string isc::util::PIDFile::getFilename ( ) const
inline

Returns the path to the PID file.

Definition at line 82 of file pid_file.h.

◆ write() [1/2]

void isc::util::PIDFile::write ( int  pid) const

Write the PID to the file.

Parameters
pidthe pid to write to the file.
Exceptions
throwsPIDFileError if it can't open or write to the PID file.

Definition at line 63 of file pid_file.cc.

References isc_throw.

Referenced by isc::lfc::LFCController::launch().

◆ write() [2/2]

void isc::util::PIDFile::write ( ) const

Get PID of the current process and write it to the file.

Exceptions
throwsPIDFileError if it can't open or write to the PID file.

Definition at line 58 of file pid_file.cc.


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