Fixed looping on SIGCLD problem. Missing break & missing CatchChild...
authorJeremy Allison <jra@samba.org>
Sat, 6 Feb 1999 22:10:41 +0000 (22:10 +0000)
committerJeremy Allison <jra@samba.org>
Sat, 6 Feb 1999 22:10:41 +0000 (22:10 +0000)
DAMN !!!!!
Jeremy.

source/lib/smbrun.c
source/smbd/chgpasswd.c

index 7162b9266aef98056ba0d8694c545e020dcd95c1..366657129de80acf20a8d3392cde4c35578d1c43 100644 (file)
@@ -115,9 +115,17 @@ int smbrun(char *cmd,char *outfile,BOOL shared)
 #else
        /* in this newer method we will exec /bin/sh with the correct
           arguments, after first setting stdout to point at the file */
-       
+
+       /*
+        * We need to temporarily stop CatchChild from eating
+        * SIGCLD signals as it also eats the exit status code. JRA.
+        */
+
+       CatchChildLeaveStatus();
+                                       
        if ((pid=fork()) < 0) {
                DEBUG(0,("smbrun: fork failed with error %s\n", strerror(errno) ));
+               CatchChild(); 
                return errno;
     }
 
@@ -128,13 +136,18 @@ int smbrun(char *cmd,char *outfile,BOOL shared)
                int status=0;
                pid_t wpid;
 
+               
                /* the parent just waits for the child to exit */
                while((wpid = sys_waitpid(pid,&status,0)) < 0) {
                        if(errno == EINTR) {
                                errno = 0;
                                continue;
                        }
+                       break;
                }
+
+               CatchChild(); 
+
                if (wpid != pid) {
                        DEBUG(2,("waitpid(%d) : %s\n",pid,strerror(errno)));
                        return -1;
@@ -142,6 +155,7 @@ int smbrun(char *cmd,char *outfile,BOOL shared)
                return status;
        }
        
+       CatchChild(); 
        
        /* we are in the child. we exec /bin/sh to do the work for us. we
           don't directly exec the command we want because it may be a
index bdc7cb115928e46d54056921a1ae93a14cbf1fe8..8ba9b1e01abcf5c58e6dfe4d8daee052c558ccc8 100644 (file)
@@ -323,6 +323,7 @@ static BOOL chat_with_program(char *passwordprogram,char *name,char *chatsequenc
         errno = 0;
         continue;
       }
+         break;
     }
 
     if (wpid < 0) {