Write the PID to the specified file.
the PID file
if no PID is available.
if the file cannot be written