write a daemon pid file
() writes a file containing the
process ID of the program to the /var/run
directory. The file name has the form
. If the
argument is NULL,
will determine the program name and
use that instead.
The pid file can be used as a quick reference if the process needs to be sent a
signal. When the program exits, the pid file will be removed automatically,
unless the program receives a fatal signal.
() returns 0 on success and -1 on
function call appeared in
() is called multiple times with
, only the last pidfile
will be removed upon exit.
() to ensure the pidfile is unlinked
at program exit. However, programs that use the
() function (for example, in signal
handlers) will not trigger this behaviour.