let kill_daemon lock = if file_exists lock then let pid = try read_pid_from_file lock with x -> error (lock ^ "does not contain a pid") in printf "Killing daemon %d... %!" pid; try kill pid sigkill; printf "Done!\n%!"; handle_unix_error (fun _ -> unlink lock) () with Unix_error (EPERM,_,_) -> eprintf "Killing %d not permitted!\n%!" pid; exit 2 | _ -> eprintf "Process %d not running (cleaning %s)!\n%!" pid lock; handle_unix_error (fun _ -> unlink lock) (); exit 1 else error "Daemon not running";; |