diff options
author | Alexandre Ganea <alexandre.ganea@ubisoft.com> | 2020-09-24 08:14:45 -0400 |
---|---|---|
committer | Alexandre Ganea <alexandre.ganea@ubisoft.com> | 2020-09-24 08:21:43 -0400 |
commit | f5314d15af4f4514103ea12c74cb208538b8bef5 (patch) | |
tree | 446c418e4b8034d031609091307c9e72b4738264 /llvm/lib/Support/CrashRecoveryContext.cpp | |
parent | b3418cb4eb1456c41606f4621dcfa362fe54183c (diff) | |
download | llvm-f5314d15af4f4514103ea12c74cb208538b8bef5.zip llvm-f5314d15af4f4514103ea12c74cb208538b8bef5.tar.gz llvm-f5314d15af4f4514103ea12c74cb208538b8bef5.tar.bz2 |
[Support] On Unix, let the CrashRecoveryContext return the signal code
Before this patch, the CrashRecoveryContext was returning -2 upon a signal, like ExecuteAndWait does. This didn't match the behavior on Windows, where the the exception code was returned.
We now return the signal's code, which optionally allows for re-throwing the signal later. Doing so requires all custom handlers to be removed first, through llvm::sys::unregisterHandlers() which we made a public API.
This is part of https://reviews.llvm.org/D70378
Diffstat (limited to 'llvm/lib/Support/CrashRecoveryContext.cpp')
-rw-r--r-- | llvm/lib/Support/CrashRecoveryContext.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/llvm/lib/Support/CrashRecoveryContext.cpp b/llvm/lib/Support/CrashRecoveryContext.cpp index 2a41754..7609f04 100644 --- a/llvm/lib/Support/CrashRecoveryContext.cpp +++ b/llvm/lib/Support/CrashRecoveryContext.cpp @@ -375,9 +375,10 @@ static void CrashRecoverySignalHandler(int Signal) { sigaddset(&SigMask, Signal); sigprocmask(SIG_UNBLOCK, &SigMask, nullptr); - // As per convention, -2 indicates a crash or timeout as opposed to failure to - // execute (see llvm/include/llvm/Support/Program.h) - int RetCode = -2; + // Return the same error code as if the program crashed, as mentioned in the + // section "Exit Status for Commands": + // https://pubs.opengroup.org/onlinepubs/9699919799/xrat/V4_xcu_chap02.html + int RetCode = 128 + Signal; // Don't consider a broken pipe as a crash (see clang/lib/Driver/Driver.cpp) if (Signal == SIGPIPE) |