fix write_pid called after daemonize call

To control daemonized process, we must call write_pid
after the daemonize() call.

Signed-off-by: Hiroaki KAWAI <kawai@stratosphere.co.jp>