From dc29d55b30d95f0838499fb48217e1d22e39d07d Mon Sep 17 00:00:00 2001 From: Simon Marlow Date: Mon, 1 Oct 2012 11:48:14 +0100 Subject: 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. --- System/Posix/Process/Internals.hs | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'System') 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 + -- cgit v1.2.3