qpid::sys::LockFile Class Reference

LockFile represents a locked file suitable for a coarse-grain system lock. More...

#include <LockFile.h>

List of all members.

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.


Detailed Description

LockFile represents a locked file suitable for a coarse-grain system lock.

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.


Member Function Documentation

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.

Returns:
The stored process ID. No validity check is done on it.

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.


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

Generated on Thu Oct 16 13:38:39 2008 for Qpid by  doxygen 1.5.6