add support for writing pid file