aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar Lukacs Berki <lberki@google.com>2016-10-28 12:39:38 +0000
committerGravatar John Cater <jcater@google.com>2016-10-28 16:03:05 +0000
commit72bdef6eb89ab5da6511344cf4bee6ec67562020 (patch)
tree9a8eb165226d7393eae1c76edc951889cd56cca1 /src
parent4885eefffe11d5623eb478328f9fdc88fbcc6345 (diff)
Reap the direct child process when double-forking to daemonize.
Otherwise, it'd only be reaped by init when the client terminates. -- MOS_MIGRATED_REVID=137502970
Diffstat (limited to 'src')
-rw-r--r--src/main/cpp/blaze_util_posix.cc3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/main/cpp/blaze_util_posix.cc b/src/main/cpp/blaze_util_posix.cc
index 0022da3da9..7b4718ad90 100644
--- a/src/main/cpp/blaze_util_posix.cc
+++ b/src/main/cpp/blaze_util_posix.cc
@@ -18,6 +18,7 @@
#include <signal.h>
#include <stdio.h>
#include <sys/types.h>
+#include <sys/wait.h>
#include <unistd.h>
#include "src/main/cpp/blaze_util.h"
@@ -145,6 +146,8 @@ void ExecuteDaemon(const string& exe,
pdie(blaze_exit_code::INTERNAL_ERROR, "fork() failed");
} else if (child > 0) { // we're the parent
close(fds[1]); // parent keeps only the reading side
+ int unused_status;
+ waitpid(child, &unused_status, 0); // child double-forks
*server_startup = new PipeBlazeServerStartup(fds[0]);
return;
} else {