Support writing out a pid file

Support writing out a pid file