[llvm] 9a3f892 - [Signal] Allow one-shot SIGPIPE handler to be reached

Vedant Kumar via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 4 19:38:31 PST 2019


Author: Vedant Kumar
Date: 2019-12-04T19:38:19-08:00
New Revision: 9a3f892d018238dce5181e458905311db8e682f5

URL: https://github.com/llvm/llvm-project/commit/9a3f892d018238dce5181e458905311db8e682f5
DIFF: https://github.com/llvm/llvm-project/commit/9a3f892d018238dce5181e458905311db8e682f5.diff

LOG: [Signal] Allow one-shot SIGPIPE handler to be reached

As SIGPIPE is no longer in the IntSigs array, handle SIGPIPE before
handling any interrupt signals.

Thanks to Alexandre Ganea for pointing out the issue here.

Added: 
    

Modified: 
    llvm/lib/Support/Unix/Signals.inc

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Support/Unix/Signals.inc b/llvm/lib/Support/Unix/Signals.inc
index 8c26fa9b8f29..2b31672670c8 100644
--- a/llvm/lib/Support/Unix/Signals.inc
+++ b/llvm/lib/Support/Unix/Signals.inc
@@ -361,16 +361,16 @@ static RETSIGTYPE SignalHandler(int Sig) {
   {
     RemoveFilesToRemove();
 
+    if (Sig == SIGPIPE)
+      if (auto OldOneShotPipeFunction =
+              OneShotPipeSignalFunction.exchange(nullptr))
+        return OldOneShotPipeFunction();
+
     if (std::find(std::begin(IntSigs), std::end(IntSigs), Sig)
         != std::end(IntSigs)) {
       if (auto OldInterruptFunction = InterruptFunction.exchange(nullptr))
         return OldInterruptFunction();
 
-      if (Sig == SIGPIPE)
-        if (auto OldOneShotPipeFunction =
-                OneShotPipeSignalFunction.exchange(nullptr))
-          return OldOneShotPipeFunction();
-
       raise(Sig);   // Execute the default handler.
       return;
    }


        


More information about the llvm-commits mailing list