Modified the PID file creation when daemonizing to open the file before
dropping privileges.