Implement privilege drop and pid file