Kea: isc::util::PIDLock Class Reference

| Kea 3.2.0-git

isc::util::PIDLock Class Reference

RAII device to handle a lock file to avoid race conditions. More...

`#include <pid_file.h>`

## Public Member Functions
| PIDLock (const std::string &lockname, bool blocking=false)
| Constructor.
| ~PIDLock ()
| Destructor.
bool | isLocked ()
| Return the lock status.

## Detailed Description

RAII device to handle a lock file to avoid race conditions.

Note
  If there is a missing component in the path and the lock is not blocking the lock is considered as being acquired: this does not change the behavior of PIDFile methods (check() will succeed and write() throw) and does not require unit test updates as if the constructor throws.

Definition at line 115 of file pid_file.h.

## Constructor & Destructor Documentation

## ◆ PIDLock()

isc::util::PIDLock::PIDLock | ( | const std::string & | lockname,
|  | bool | blocking = false )

Constructor.

Try to get a lock.

Parameters

  lockname | Lock filename.
  blocking | If true (default is false) block when already locked.

Definition at line 89 of file pid_file.cc.

References isc_throw.

## ◆ ~PIDLock()

isc::util::PIDLock::~PIDLock | ( |  | ) |

Destructor.

Release the lock when taken and delete the lock file.

Definition at line 117 of file pid_file.cc.

## Member Function Documentation

## ◆ isLocked()

bool isc::util::PIDLock::isLocked | ( |  | ) |
| inline

Return the lock status.

Definition at line 131 of file pid_file.h.

Referenced by isc::process::Daemon::createPIDFile(), isc::dhcp::LFCSetup::execute(), isc::dhcp::Memfile_LeaseMgr::isLFCProcessRunning(), and isc::lfc::LFCController::launch().

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

- pid_file.h
- pid_file.cc