Write the pid to a pidfile.