If we exit via preforker, call exit(3) and not recursively back into
Preforker::exit(r). Otherwise you get a hang with the child blocked
at:
Thread 1 (Thread 0x7fa08962e7c0 (LWP 5419)):
#0 0x000000309860e0cd in write () from /lib64/libpthread.so.0
#1 0x00000000005cc906 in Preforker::exit(int) ()
#2 0x00000000005c8dfb in main ()
and the parent at
#0 0x000000309860eba7 in waitpid () from /lib64/libpthread.so.0
#1 0x00000000005cc87a in Preforker::parent_wait() ()
#2 0x00000000005c75ae in main ()
Backport: cuttlefish
Signed-off-by: Sage Weil <sage@inktank.com>
int signal_exit(int r) {
if (forked) {
// tell parent
- (void)::write(fd[1], &r, sizeof(r));
+ (void)safe_write(fd[1], &r, sizeof(r));
}
return r;
}
void exit(int r) {
signal_exit(r);
- exit(r);
+ ::exit(r);
}
void daemonize() {