35 m_error_msg (
"no errors")
108 DL((
PIDFLOCK,
"CLOSE-ON-EXEC is set on FD.\n"));
139 std::ostringstream
mypid;
199 DL((
PIDFLOCK,
"fcntl(fd=%d, F_SETLK, %s) returned: %d\n",
255 DL((
PIDFLOCK,
"fcntl(fd=%d, F_SETLK, F_UNLCK) returned: %d\n",
312 DL((
PIDFLOCK,
"fcntl(fd=%d, F_GETLK, %s) returned: %d\n",
328 if (read (
m_fd,
buf, 64) > 0) {
367 DL((
PIDFLOCK,
"Failed to retrieve lock status.\n"));
376 return (this->
l_pid);
395 if (
m_fd == -1)
return;
425 "Error: \"Failed to get a lock on PID file - %s\".\n",
msg_));
453 log_error (
"PID file is already locked (by someone).");
462 log_error(
"PID file is locked by another process");
#define EL(X)
A macro for writing error message to the Logger.
#define DL(X)
A macro for writing debug message to the Logger.
#define trace_with_mask(s, m)
trace_with_mask() is used to trace function call chain in C++ program.
A utility class for creating and managing process PID lock file.
A wrapper class to provide AutoPtr with reference semantics.
int get_lock_status()
Retrieve lock status.
~PidFileLock()
Destructor.
int write_pid()
Write our process pid to the lock file.
pid_t open_pid_file(const std::string &fname_)
Open pid file in a cross-platform way.
int m_error
Last system call error.
const char * get_error_msg() const
In case of error, return a verbal description of the last error.
PidFileLock()
Constructor.
int get_error() const
Return last errno value.
void log_error(const char *msg_)
Log an error message to the log file and set internal error to errno.
pid_t test_region()
Test if file is unlocked.
string m_filename
Lock file name.
int m_fd
Lock file descriptor.
void dump()
Write the state of the lock to debug file.
bool lock(const string &filename_)
Lock the file.
int lock_region()
Lock the entire file.
int lock_region_exclusive()
Lock the entire file (only under Cygwin).
int unlock_region()
Unlock the entire file.
std::string strenv(const char *in_)
Expand the passed string in_ by substituting environment variable names for their values.
@ ASSAERR
ASSA and system errors
@ PIDFLOCK
Class PidFileLock messages