ae.sys.pidfile

PID file and lock

Members

Functions

createPidFile
void createPidFile(string name, string path)

Create and lock a PID file. If the PID file exists and is locked, an exception is thrown. To use, simply call this function at the top of main to prevent multiple instances.

defaultPidFileName
string defaultPidFileName()

The default name argument for createPidFile. Returns a file name containing the username and program name.

defaultPidFilePath
string defaultPidFilePath()

The default path argument for createPidFile. Returns "/var/run" if running as root on POSIX, or the temporary directory otherwise.

Static variables

pidFile
File pidFile;

The PID file. Kept open and locked while the program is running.

Meta

License

This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.

Authors

Vladimir Panteleev <ae@cy.md>