[commit: unix] master: Indicate whether a process dumped core in the ProcessStatus (dc29d55)

Simon Marlow marlowsd at gmail.com
Wed Jan 30 12:04:11 CET 2013


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

On branch  : master

http://hackage.haskell.org/trac/ghc/changeset/dc29d55b30d95f0838499fb48217e1d22e39d07d

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

commit dc29d55b30d95f0838499fb48217e1d22e39d07d
Author: Simon Marlow <marlowsd at gmail.com>
Date:   Mon Oct 1 11:48:14 2012 +0100

    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 +++++++++++++++------
 cbits/HsUnix.c                    |    1 +
 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;} 





More information about the ghc-commits mailing list