aboutsummaryrefslogtreecommitdiffhomepage
path: root/System
diff options
context:
space:
mode:
authorGravatar Simon Marlow <marlowsd@gmail.com>2012-10-01 11:48:14 +0100
committerGravatar Simon Marlow <marlowsd@gmail.com>2013-01-25 20:54:39 +0000
commitdc29d55b30d95f0838499fb48217e1d22e39d07d (patch)
tree226fbf943fdaa5209a77adc77295cad87a21ff4b /System
parentaf75e09945582b5e3b723f033216936121f3f65e (diff)
Indicate whether a process dumped core in the ProcessStatus
The Bool field of Terminated is new, as is the documentation: 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 is an API change, hence will need a major version bump.
Diffstat (limited to 'System')
-rw-r--r--System/Posix/Process/Internals.hs21
1 files changed, 15 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
+