Commit 18ba2d27 authored by Niels Möller's avatar Niels Möller

(daemon_init): When backgrounding, let the parent

process use _exit rather than exit. We used to let the
intermediate process wait on the child, in order to print out a
message for any unexpected status code. But then we get a race in
the testsuite, because that process may keep the listen sockets
open even after the main process has deleted its pid file.

Rev: src/daemon.c:1.15
parent bcbc2836
......@@ -279,7 +279,7 @@ daemon_init(enum daemon_mode mode)
break;
default:
/* Parent */
exit(0);
_exit(0);
}
/* Become a process session leader. */
......@@ -299,28 +299,7 @@ daemon_init(enum daemon_mode mode)
case 0:
break;
default:
{
int status;
int res;
do {
res = waitpid(child, &status, 0);
} while (res < 0 && errno == EINTR);
if (!res < 0)
werror("deamon.c: waitpid failed %e\n", errno);
else if (WIFEXITED(status))
werror("deamon.c: process exited with status %i\n",
WEXITSTATUS(status));
else if (WIFSIGNALED(status))
werror("deamon.c: process died from signal %i\n",
WTERMSIG(status));
else
werror("deamon.c: process died, wait status: %i\n",
status);
_exit(0);
}
_exit(0);
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment