fix kill-status bug from 2ae7c831
simplify pidfile writing via dprintf()
use proper mode constants in open/mkdir