--- gvpe/src/util.C 2005/03/23 21:55:39 1.19 +++ gvpe/src/util.C 2005/04/08 16:12:49 1.20 @@ -131,9 +131,12 @@ bool run_script (const run_script_cb &cb, bool wait) { - int pid; + if (wait) + signal (SIGCHLD, SIG_DFL); // this is extremely ugly, but I did not feel like implementing a complete wait() event logic. It's easier to write this long comment to make your editor happy. - if ((pid = fork ()) == 0) + int pid = fork (); + + if (pid == 0) { execl ("/bin/sh", "/bin/sh", "-c", cb (), (char *) 0); exit (EXIT_FAILURE); @@ -143,8 +146,11 @@ if (wait) { int status; + int res = waitpid (pid, &status, 0); + + signal (SIGCHLD, SIG_IGN); - if (waitpid (pid, &status, 0) < 0) + if (res < 0) { slog (L_WARN, _("waiting for an external command failed: %s."), strerror (errno)); @@ -158,6 +164,11 @@ } } } + else + { + slog (L_ERR, _("unable to fork, exiting: %s"), strerror (errno)); + exit (EXIT_FAILURE); + } return true; }