Next: posix pid-files config, Up: posix pid-files [Index]
A PID file is a textual file in ASCII encoding created at process start time and deleted at process exit time; it contains a string representing the PID number of the current process followed by a newline character.
The PID file is especially useful whenever a server is executed as daemon: it allows for quick retrieval of the PID number, which can be used to send interprocess signals to the daemon; for example: to shut it down, to restart it, to update its configuration.
When a PID file is used: the creator process should refuse to start if the PID file already exists, because it may mean that a program instance is already in execution.
The PID file must be created after a server daemonisation process has completed: this way we correctly store the PID of the daemon process, rather than the PID of the starting process.
The PID file must be created after a process has changed its user and group IDs to drop special privileges: this way the file is created with appropriate owner and group.
All the operations performed by this library are logged. Logging operations related to the PID file rely on the function referenced by an internal parameter; we just need to configure this parameter with an appropriate function.