Skip to content

Commit

Permalink
Give an explicit message when SIGSEGV happens.
Browse files Browse the repository at this point in the history
Fixes haskell#767.

Signed-off-by: Edward Z. Yang <[email protected]>
  • Loading branch information
ezyang committed Aug 22, 2016
1 parent 4a9f11e commit 44b57e5
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion cabal-install/Distribution/Client/ProjectOrchestration.hs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ import Data.Either
import Control.Exception (Exception(..))
import System.Exit (ExitCode(..), exitFailure)
#ifdef MIN_VERSION_unix
import System.Posix.Signals (sigKILL)
import System.Posix.Signals (sigKILL, sigSEGV)
#endif


Expand Down Expand Up @@ -651,7 +651,27 @@ reportBuildFailures verbosity plan buildOutcomes
Just (ExitFailure 1) -> ""

#ifdef MIN_VERSION_unix
-- Note [Positive "signal" exit code]
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-- What's the business with the test for negative and positive
-- signal values? The API for process specifies that if the
-- process died due to a signal, it returns a *negative* exit
-- code. So that's the negative test.
--
-- What about the positive test? Well, when we find out that
-- a process died due to a signal, we ourselves exit with that
-- exit code. However, we don't "kill ourselves" with the
-- signal; we just exit with the same code as the signal: thus
-- the caller sees a *positive* exit code. So that's what
-- happens when we get a positive exit code.
Just (ExitFailure n)
| -n == fromIntegral sigSEGV ->
" The build process segfaulted (i.e. SIGSEGV)."

| n == fromIntegral sigSEGV ->
" The build process terminated with exit code " ++ show n
++ " which may be because some part of it segfaulted. (i.e. SIGSEGV)."

| -n == fromIntegral sigKILL ->
" The build process was killed (i.e. SIGKILL). " ++ explanation

Expand Down

0 comments on commit 44b57e5

Please sign in to comment.