Browse Source

* Possibly fixed Defunct bug

svn: 333
Bryan Drewery 22 years ago
parent
commit
a12fca836e
1 changed files with 6 additions and 2 deletions
  1. 6 2
      src/misc.c

+ 6 - 2
src/misc.c

@@ -1123,8 +1123,8 @@ int shell_exec(char *cmdline, char *input, char **output, char **erroutput)
    *outFile,
    *errFile;
   char tmpfile[161];
-  int x,
-    fd;
+  int x, fd;
+  int parent = getpid();
 
   if (!cmdline)
     return 0;
@@ -1232,12 +1232,15 @@ int shell_exec(char *cmdline, char *input, char **output, char **erroutput)
     outd = fileno(outFile);
     errd = fileno(errFile);
     if (dup2(ind, STDIN_FILENO) == (-1)) {
+      kill(parent, SIGCHLD);
       exit(1);
     }
     if (dup2(outd, STDOUT_FILENO) == (-1)) {
+      kill(parent, SIGCHLD);
       exit(1);
     }
     if (dup2(errd, STDERR_FILENO) == (-1)) {
+      kill(parent, SIGCHLD);
       exit(1);
     }
     argv[0] = STR("sh");
@@ -1245,6 +1248,7 @@ int shell_exec(char *cmdline, char *input, char **output, char **erroutput)
     argv[2] = cmdline;
     argv[3] = NULL;
     execvp(argv[0], &argv[0]);
+    kill(parent, SIGCHLD);
     exit(1);
   }