Package: sysvinit
Version: 2.85-1

Is there a race condition in init?  While looking at the sysvinit
patches used by SuSe, I came across a patch to fix a race condition.
The code still applies, with a huge offset.  This is the patch from
suse:

--- src/init.c
+++ src/init.c  Fri Mar 12 12:47:22 2004
@@ -26,6 +26,11 @@
  *             did_boot made global and added to state - thanks, Miquel.
  *             Yet another file descriptors leak - close state pipe if 
  *             re_exec fails.
+ *             4 Sep 2001, Andrea Arcangeli:
+ *             Fix a race in spawn() that is used to deadlock init in a
+ *             waitpid() loop: must set the childhandler as default before 
forking
+ *             off the child or the chld_handler could run before the waitpid 
loop
+ *             has a chance to find its zombie-child.
  */
 
 #include <sys/types.h>
@@ -895,6 +900,7 @@
                                dup(f);
                                dup(f);
                        }
+                       SETSIG(sa, SIGCHLD, SIG_DFL, SA_RESTART);
                        if ((pid = fork()) < 0) {
                                log(L_VB, "cannot fork");
                                exit(1);
@@ -907,7 +913,6 @@
                                SETSIG(sa, SIGINT, SIG_IGN, SA_RESTART);
                                SETSIG(sa, SIGTSTP, SIG_IGN, SA_RESTART);
                                SETSIG(sa, SIGQUIT, SIG_IGN, SA_RESTART);
-                               SETSIG(sa, SIGCHLD, SIG_DFL, SA_RESTART);
 
                                while ((rc = waitpid(pid, &st, 0)) != pid)
                                        if (rc < 0 && errno == ECHILD)

And this is the patch relative to the current version in debian:

Index: src/init.c
===================================================================
--- src/init.c  (revisjon 56)
+++ src/init.c  (arbeidskopi)
@@ -966,6 +966,7 @@
                                dup(f);
                                dup(f);
                        }
+                       SETSIG(sa, SIGCHLD, SIG_DFL, SA_RESTART);
                        if ((pid = fork()) < 0) {
                                initlog(L_VB, "cannot fork");
                                exit(1);
@@ -978,7 +979,6 @@
                                SETSIG(sa, SIGINT, SIG_IGN, SA_RESTART);
                                SETSIG(sa, SIGTSTP, SIG_IGN, SA_RESTART);
                                SETSIG(sa, SIGQUIT, SIG_IGN, SA_RESTART);
-                               SETSIG(sa, SIGCHLD, SIG_DFL, SA_RESTART);
 
                                while ((rc = waitpid(pid, &st, 0)) != pid)
                                        if (rc < 0 && errno == ECHILD)

My understanding of fork() tell me that this is a valid patch.  Am I
misunderstanding something?


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to