#include <LockFile.h>
Public Member Functions | |
LockFile (const std::string &path_, bool create) | |
pid_t | readPid (void) const |
Read the process ID from the lock file. | |
void | writePid (void) |
Write the current process's ID to the lock file. |
For example, the broker uses this to ensure that only one broker runs. A common usage idiom is to store the current "owner" process ID in the lock file - if the lock file exists, but the stored process ID doesn't, the old owner has probably died without cleaning up the lock file.
Definition at line 43 of file LockFile.h.
pid_t qpid::sys::LockFile::readPid | ( | void | ) | const |
Read the process ID from the lock file.
This method assumes that if there is a process ID in the file, it was written there by writePid(); thus, it's at the start of the file.
Throws an exception if there is an error reading the file.
void qpid::sys::LockFile::writePid | ( | void | ) |
Write the current process's ID to the lock file.
It's written at the start of the file and will overwrite any other content that may be in the file.
Throws an exception if the write fails.