Kea 2.7.5
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.
 
 ~PIDFile ()
 Destructor.
 
int check () const
 Read the PID in from the file and check it.
 
void deleteFile () const
 Delete the PID file.
 
std::string getFilename () const
 Returns the path to the PID file.
 
void write () const
 Get PID of the current process and write it to the file.
 
void write (int) const
 Write the PID to the file.
 

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.

◆ 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.

◆ 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 ( ) 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.

References write().

Referenced by write().

+ Here is the call graph for this function:

◆ write() [2/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.


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