Repository : ssh://darcs.haskell.org//srv/darcs/packages/process

On branch  : master

http://hackage.haskell.org/trac/ghc/changeset/54038240284b11ad4117ca075fa2292f5069bc45

>---------------------------------------------------------------

commit 54038240284b11ad4117ca075fa2292f5069bc45
Author: Simon Marlow <[email protected]>
Date:   Mon Sep 24 09:50:24 2012 +0100

    Use (128+signal) as the exit code when a proc terminates due to a signal 
(#7229)

>---------------------------------------------------------------

 cbits/runProcess.c |   13 ++++++++++---
 1 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/cbits/runProcess.c b/cbits/runProcess.c
index 6154d1d..5783092 100644
--- a/cbits/runProcess.c
+++ b/cbits/runProcess.c
@@ -22,6 +22,13 @@
    UNIX versions
    ------------------------------------------------------------------------- */
 
+//
+// If a process terminates with a signal, the exit status we return to
+// via the System.Process API follows the Unix shell convention of
+// (128 + signal).
+//
+#define TERMSIG_STATUS(r) ((r) | 0x80)
+
 static long max_fd = 0;
 
 // Rts internal API, not exposed in a public header file:
@@ -245,8 +252,8 @@ getProcessExitCode (ProcHandle handle, int *pExitCode)
        else
            if (WIFSIGNALED(wstat))
            {
-               errno = EINTR;
-               return -1;
+                *pExitCode = TERMSIG_STATUS(WTERMSIG(wstat));
+                return 1;
            }
            else
            {
@@ -281,7 +288,7 @@ int waitForProcess (ProcHandle handle, int *pret)
     else
        if (WIFSIGNALED(wstat))
        {
-            *pret = wstat;
+            *pret = TERMSIG_STATUS(WTERMSIG(wstat));
            return 0;
        }
        else



_______________________________________________
Cvs-libraries mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/cvs-libraries

Reply via email to