[clang] [clang-tools-extra] [llvm] [LLVM][CLANG] Update signal-handling behavior to comply with POSIX (PR #169340)
David Tenty via cfe-commits
cfe-commits at lists.llvm.org
Wed Feb 18 07:54:49 PST 2026
================
@@ -471,6 +475,18 @@ int clang_main(int Argc, char **Argv, const llvm::ToolContext &ToolContext) {
Res = 1;
#endif
+#if LLVM_ON_UNIX
+ // On Unix, signals are represented by return codes of 128 plus the signal
+ // number. If the return code indicates it was from a signal handler, raise
+ // the signal so that the exit code includes the signal number, as required
+ // by POSIX. Return code 255 is excluded because some tools, such as
+ // llvm-ifs, exit with code 255 (-1) on failure.
+ if (CommandRes > 128 && CommandRes != 255) {
----------------
daltenty wrote:
My only worry here is that not all programs the driver invokes are necessarily unix utilities (though many are), so it’s possible the exit code might not actually represent a signal value.
That said, I don't think there's much we can do other than to handle it on a case-by-case base as you did with llvm-ifs here, so I think think this is the best we can do for now.
https://github.com/llvm/llvm-project/pull/169340
More information about the cfe-commits
mailing list