(childhandler): watch for child `wait_on_pid' to die.

(recv_conn): set `wait_on_pid' instead of looping on waitpid here
also.  This should solve the problem of kxd looping which was caused
by the signal handler getting invoked before this waitpid and reaping
the child leaving this poor loop without any child


git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@6894 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
Assar Westerlund
1999-09-02 19:09:25 +00:00
parent bb532116f7
commit 37af8f3e75

View File

@@ -40,6 +40,9 @@
RCSID("$Id$");
static pid_t wait_on_pid = -1;
static int done = 0;
/*
* Signal handler that justs waits for the children when they die.
*/
@@ -52,6 +55,8 @@ childhandler (int sig)
do {
pid = waitpid (-1, &status, WNOHANG|WUNTRACED);
if (pid > 0 && pid == wait_on_pid)
done = 1;
} while(pid > 0);
signal (SIGCHLD, childhandler);
SIGRETURN(0);
@@ -204,12 +209,9 @@ recv_conn (int sock, kx_context *kc,
cleanup (*nsockets, *sockets);
fatal (kc, sock, "fork: %s", strerror(errno));
} else if (pid != 0) {
int status;
while (waitpid (pid, &status, 0) != pid
&& !WIFEXITED(status)
&& !WIFSIGNALED(status))
;
wait_on_pid = pid;
while (!done)
pause ();
cleanup (*nsockets, *sockets);
exit (0);
}