crane-domain: Add PID file writing routine
crane-domain: Add PID file writing routine

NOTE:
- PID writing routine is modified from PID reading routine
  so, it must be checked again for errors
- Add errno = 0 (clear error) to prevent unrelevant failure

nieltg/line-masterbot