X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=cbits%2FrunProcess.c;h=83586056f6ccf2ffc18942f842a7b7f87b02438a;hb=e0062ebb3e48285f0649cd3ef9d71135829ba965;hp=efe9ea973ed045048a8cacea70ee484e95b0276c;hpb=edad1f42b5dfea7aaf640aaae808c14e6138551a;p=ghc-base.git diff --git a/cbits/runProcess.c b/cbits/runProcess.c index efe9ea9..8358605 100644 --- a/cbits/runProcess.c +++ b/cbits/runProcess.c @@ -6,7 +6,7 @@ #include "HsBase.h" -#if defined(mingw32_TARGET_OS) +#if defined(mingw32_HOST_OS) #include #include #endif @@ -23,14 +23,16 @@ #include #endif -#if !defined(mingw32_TARGET_OS) && !defined(__MINGW32__) +#if !defined(mingw32_HOST_OS) && !defined(__MINGW32__) /* ---------------------------------------------------------------------------- UNIX versions ------------------------------------------------------------------------- */ -int +ProcHandle runProcess (char *const args[], char *workingDirectory, char **environment, - int fdStdInput, int fdStdOutput, int fdStdError) + int fdStdInput, int fdStdOutput, int fdStdError, + int set_inthandler, long inthandler, + int set_quithandler, long quithandler) { int pid; struct sigaction dfl; @@ -48,27 +50,18 @@ runProcess (char *const args[], char *workingDirectory, char **environment, chdir (workingDirectory); } - /* - * Restore SIGINT and SIGQUIT to default actions - * - * Glyn Clemments writes: - * For your purposes, runProcess + waitForProcess is probably - * the way to go. Except that runProcess appears to be missing - * the usual signal handling. system() ignores SIGINT and - * SIGQUIT in the parent, and resets them to their defaults in - * the child; it also blocks SIGCHLD in the parent. runProcess - * may need to do something similar; it should probably at - * least reset SIGINT and SIGQUIT in the child, in case they - * are ignored in the parent. The parent can set up its own - * signal handling, but the only place it can control the - * child's signal handling is between the fork() and the - * exec(), so if runProcess doesn't do it, it won't get done. + /* Set the SIGINT/SIGQUIT signal handlers in the child, if requested */ - dfl.sa_handler = SIG_DFL; (void)sigemptyset(&dfl.sa_mask); dfl.sa_flags = 0; - (void)sigaction(SIGINT, &dfl, NULL); - (void)sigaction(SIGQUIT, &dfl, NULL); + if (set_inthandler) { + dfl.sa_handler = (void *)inthandler; + (void)sigaction(SIGINT, &dfl, NULL); + } + if (set_quithandler) { + dfl.sa_handler = (void *)quithandler; + (void)sigaction(SIGQUIT, &dfl, NULL); + } dup2 (fdStdInput, STDIN_FILENO); dup2 (fdStdOutput, STDOUT_FILENO);