aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--System/Posix/Process/Internals.hs21
-rw-r--r--cbits/HsUnix.c1
2 files changed, 16 insertions, 6 deletions
diff --git a/System/Posix/Process/Internals.hs b/System/Posix/Process/Internals.hs
index 0ff88d8..b5017c5 100644
--- a/System/Posix/Process/Internals.hs
+++ b/System/Posix/Process/Internals.hs
@@ -12,10 +12,15 @@ import System.Exit
import System.IO.Error
import GHC.Conc (Signal)
-data ProcessStatus = Exited ExitCode
- | Terminated Signal
- | Stopped Signal
- deriving (Eq, Ord, Show)
+-- | The exit status of a process
+data ProcessStatus
+ = Exited ExitCode -- ^ the process exited by calling
+ -- @exit()@ or returning from @main@
+ | Terminated Signal Bool -- ^ the process was terminated by a
+ -- signal, the @Bool@ is @True@ if a core
+ -- dump was produced
+ | Stopped Signal -- ^ the process was stopped by a signal
+ deriving (Eq, Ord, Show)
-- this function disables the itimer, which would otherwise cause confusing
-- signals to be sent to the new process.
@@ -36,8 +41,9 @@ decipherWaitStatus wstat =
else do
if c_WIFSIGNALED wstat /= 0
then do
- let termsig = c_WTERMSIG wstat
- return (Terminated termsig)
+ let termsig = c_WTERMSIG wstat
+ let coredumped = c_WCOREDUMP wstat /= 0
+ return (Terminated termsig coredumped)
else do
if c_WIFSTOPPED wstat /= 0
then do
@@ -65,3 +71,6 @@ foreign import ccall unsafe "__hsunix_wifstopped"
foreign import ccall unsafe "__hsunix_wstopsig"
c_WSTOPSIG :: CInt -> CInt
+foreign import ccall unsafe "__hsunix_wcoredump"
+ c_WCOREDUMP :: CInt -> CInt
+
diff --git a/cbits/HsUnix.c b/cbits/HsUnix.c
index aba5445..db97de2 100644
--- a/cbits/HsUnix.c
+++ b/cbits/HsUnix.c
@@ -14,6 +14,7 @@ int __hsunix_wifsignaled (int stat) { return WIFSIGNALED(stat); }
int __hsunix_wtermsig (int stat) { return WTERMSIG(stat); }
int __hsunix_wifstopped (int stat) { return WIFSTOPPED(stat); }
int __hsunix_wstopsig (int stat) { return WSTOPSIG(stat); }
+int __hsunix_wcoredump (int stat) { return WCOREDUMP(stat); }
#ifdef HAVE_RTLDNEXT
void *__hsunix_rtldNext (void) {return RTLD_NEXT;}