[commit: process] master: Use (128+signal) as the exit code when a proc terminates due to a signal (#7229) (5403824)
Simon Marlow
marlowsd at gmail.com
Mon Sep 24 13:11:44 CEST 2012
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 <marlowsd at gmail.com>
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
More information about the Cvs-libraries
mailing list