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.
The default name argument for createPidFile. Returns a file name containing the username and program name.
The default path argument for createPidFile. Returns "/var/run" if running as root on POSIX, or the temporary directory otherwise.
The PID file. Kept open and locked while the program is running.
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/.
PID file and lock