Skip to content

Commit 6713d10

Browse files
Merge pull request #116 from simonjbeaumont/cp-15132
CP-15132/CA-204487: daemonize: Wait for parent to exit before writing PID file
2 parents eeab685 + fb75bad commit 6713d10

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

lib/xcp_service.ml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -552,6 +552,8 @@ let daemonize () =
552552
| 0 ->
553553
Unix.chdir "/";
554554
mkdir_rec (Filename.dirname !pidfile) 0o755;
555+
(* wait for parent to exit before writing pidfile *)
556+
while not (have_daemonized ()) do Thread.delay 0.1 done;
555557
pidfile_write !pidfile;
556558
Unix.close Unix.stdin;
557559
Unix.close Unix.stdout;

0 commit comments

Comments
 (0)