![]() |
Kea 3.1.3
|
Class to help with processing PID files. More...
#include <pid_file.h>
Public Member Functions | |
PIDFile (const std::string &filename) | |
Constructor. | |
virtual | ~PIDFile ()=default |
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. | |
std::string | getLockname () const |
Returns the path to the lock 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. | |
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.
|
inline |
|
virtualdefault |
Destructor.
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.
The PID file should be locked to avoid a race condition.
throws | PIDCantReadPID if it was able to open the file but was unable to read the PID from it. |
Definition at line 23 of file pid_file.cc.
References isc_throw.
Referenced by isc::dhcp::LFCSetup::execute(), isc::dhcp::Memfile_LeaseMgr::isLFCProcessRunning(), and isc::lfc::LFCController::launch().
void isc::util::PIDFile::deleteFile | ( | ) | const |
Delete the PID file.
This is an atomic operation not subject to a race condition.
throws | PIDFileError if it can't delete the PID file |
Definition at line 81 of file pid_file.cc.
References isc_throw.
Referenced by isc::dhcp::LFCSetup::execute(), and isc::lfc::LFCController::launch().
|
inline |
Returns the path to the PID file.
Definition at line 92 of file pid_file.h.
|
inline |
Returns the path to the lock file.
Definition at line 97 of file pid_file.h.
Referenced by isc::dhcp::LFCSetup::execute(), isc::dhcp::Memfile_LeaseMgr::isLFCProcessRunning(), and isc::lfc::LFCController::launch().
void isc::util::PIDFile::write | ( | ) | const |
Get PID of the current process and write it to the file.
The PID file must be locked to avoid a race condition.
throws | PIDFileError if it can't open or write to the PID file. |
Definition at line 55 of file pid_file.cc.
References write().
Referenced by write().
void isc::util::PIDFile::write | ( | int | pid | ) | const |
Write the PID to the file.
The PID file must be locked to avoid a race condition.
pid | the pid to write to the file. |
throws | PIDFileError if it can't open or write to the PID file. |
Definition at line 60 of file pid_file.cc.
References isc_throw.
Referenced by isc::dhcp::LFCSetup::execute(), and isc::lfc::LFCController::launch().