[PATCH] D124607: Add an error message to the default SIGPIPE handler

Damian Malarczyk via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 28 04:49:45 PDT 2022


dmcyk created this revision.
dmcyk added reviewers: davide, ab, jhenderson.
Herald added subscribers: dexonsmith, hiraditya.
Herald added a project: All.
dmcyk requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

UNIX03 conformance requires utilities to flush stdout before exiting and raise
an error if writing fails. Flushing already happens on a call to exit
and thus automatically on a return from main. Write failure is then
detected by LLVM's default SIGPIPE handler. The handler already exits with
a non-zero code, but conformance additionally requires an error message.

rdar://89760992


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D124607

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


Index: llvm/lib/Support/Unix/Signals.inc
===================================================================
--- llvm/lib/Support/Unix/Signals.inc
+++ llvm/lib/Support/Unix/Signals.inc
@@ -432,6 +432,10 @@
 }
 
 void llvm::sys::DefaultOneShotPipeSignalHandler() {
+  // UNIX03 conformance requires a non-zero exit code and an error message
+  // to stderr when writing to a closed stdout fails.
+  errs() << "error: write on a pipe with no reader\n";
+
   // Send a special return code that drivers can check for, from sysexits.h.
   exit(EX_IOERR);
 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D124607.425746.patch
Type: text/x-patch
Size: 553 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220428/bd0ee02b/attachment.bin>


More information about the llvm-commits mailing list