OSDN Git Service

[Signal] Re-raise SIGPIPE if the handler is uninstalled
authorVedant Kumar <vsk@apple.com>
Fri, 8 Jan 2021 19:12:08 +0000 (11:12 -0800)
committerVedant Kumar <vsk@apple.com>
Fri, 8 Jan 2021 19:13:43 +0000 (11:13 -0800)
Instead of falling through to RunSignalHandlers after the SIGPIPE
handler is uninstalled and we get a SIGPIPE, re-raise the signal, just
like we do for other IntSigs.

This was discussed and informally OK'd here:

https://reviews.llvm.org/rG9a3f892d018238dce5181e458905311db8e682f5#856804

llvm/lib/Support/Unix/Signals.inc

index 1ac2e09..3d7b5d2 100644 (file)
@@ -382,13 +382,15 @@ static RETSIGTYPE SignalHandler(int Sig) {
               OneShotPipeSignalFunction.exchange(nullptr))
         return OldOneShotPipeFunction();
 
-    if (llvm::is_contained(IntSigs, Sig)) {
+    bool IsIntSig = llvm::is_contained(IntSigs, Sig);
+    if (IsIntSig)
       if (auto OldInterruptFunction = InterruptFunction.exchange(nullptr))
         return OldInterruptFunction();
 
-      raise(Sig);   // Execute the default handler.
+    if (Sig == SIGPIPE || IsIntSig) {
+      raise(Sig); // Execute the default handler.
       return;
-   }
+    }
   }
 
   // Otherwise if it is a fault (like SEGV) run any handler.