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 (* "%!" flushes the output in version 3.07 *) printf "Killing daemon %d... %!" pid; if succeed (fun _ -> kill pid sigkill) () then begin printf "Done!\n%!"; handle_unix_error (fun _ -> unlink lock) () end else begin eprintf "Process %d not running (cleaning %s)!\n%!" pid lock; handle_unix_error (fun _ -> unlink lock) (); exit 1 end else error "Daemon not running";; |