[distcc] 0.5rc2
Martin Pool
mbp at samba.org
Thu Jun 27 23:47:02 GMT 2002
Actually, please try this one instead; I think SA_RESTART is wrong.
--
Martin
--- dparent.c.~1.8.~ Thu Jun 27 21:33:06 2002
+++ dparent.c Fri Jun 28 16:43:18 2002
@@ -147,14 +147,7 @@ static void dcc_reap_kids(void)
kid = waitpid(WAIT_ANY, &status, WNOHANG);
if (kid == 0) {
break;
- } else if (kid == -1) {
- if (errno == ECHILD) {
- break;
- } else {
- rs_log_error("wait failed: %s", strerror(errno));
- dcc_exit(EXIT_DISTCC_FAILED);
- }
- } else {
+ } else if (kid != -1) {
/* child exited */
--nkids;
rs_log_info("down to %d kids", nkids);
@@ -166,6 +159,15 @@ static void dcc_reap_kids(void)
rs_log_notice("child %d exited: status %d",
(int) kid, WEXITSTATUS(status));
}
+ } else if (errno == ECHILD) {
+ /* No children left? That's ok, we'll go back to waiting
+ * for new connections. */
+ break;
+ } else if (errno == EAGAIN || errno == EINTR) {
+ continue; /* loop again */
+ } else {
+ rs_log_error("wait failed: %s", strerror(errno));
+ dcc_exit(EXIT_DISTCC_FAILED);
}
}
}
--- exec.c.~1.28.~ Fri Jun 28 11:38:19 2002
+++ exec.c Fri Jun 28 16:41:48 2002
@@ -150,18 +150,33 @@ int dcc_spawn_child(char **argv, pid_t *
}
+/**
+ * Blocking wait for a child to exit. This is used when waiting for
+ * cpp, gcc, etc.
+ *
+ * This is not used by the daemon-parent; it has its own
+ * implementation in dcc_reap_kids(). They could be unified, but the
+ * parent only waits when it thinks a child has exited; the child
+ * waits all the time.
+ **/
int dcc_wait_child(pid_t pid, int *wait_status)
{
/* TODO: Need to parse command result; command failing does
* not mean we want to give up straight away, because the
* client needs to see errors, warning messages, etc. */
- if (waitpid(pid, wait_status, 0) == -1) {
- rs_log_error("waitpid borked: %s", strerror(errno));
- return -1;
+ while (1) {
+ if (waitpid(pid, wait_status, 0) != 1) {
+ rs_trace("child %d terminated with status %#x", pid,
+ *wait_status);
+ return 0;
+ } else if (errno == EAGAIN || errno == EINTR) {
+ /* huh, try again */
+ continue;
+ } else {
+ rs_log_error("waitpid borked: %s", strerror(errno));
+ return -1;
+ }
}
- rs_trace("child %d terminated with status %#x", pid,
- *wait_status);
- return 0;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://lists.samba.org/archive/distcc/attachments/20020627/d03def49/attachment.bin
More information about the distcc
mailing list