[PATCH] D138244: Revert "Reapply: Add an error message to the default SIGPIPE handler"

Bill Wendling via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 17 16:14:02 PST 2022


void created this revision.
void added reviewers: t.p.northover, kees, nickdesaulniers, nathanchance.
Herald added a subscriber: hiraditya.
Herald added a project: All.
void requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

This patch is spamming compiles with unhelpful and confusing messages.
E.g. the Linux kernel uses "grep -q" in several places. It's meant to
quit with a return code of zero when the first match is found. This can
cause a SIGPIPE signal, but that's expected. Worse, there's no way to
turn this error message off. We can only pipe it to /dev/null, which is
a bit awkward.

Is UNIX03 conformance something Clang is striving for? If so, then we
need a much better solution than to emit an error message that we can't
quiet.

This reverts commit b89bcefa6202e310eb3167dd1c37f1807377ec8d <https://reviews.llvm.org/rGb89bcefa6202e310eb3167dd1c37f1807377ec8d>.

Link: https://github.com/ClangBuiltLinux/linux/issues/1651


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D138244

Files:
  llvm/lib/Support/Unix/Signals.inc
  llvm/test/Support/unix03-sigpipe-exit.test


Index: llvm/test/Support/unix03-sigpipe-exit.test
===================================================================
--- llvm/test/Support/unix03-sigpipe-exit.test
+++ /dev/null
@@ -1,26 +0,0 @@
-## Test that when writing to a closed stdout, LLVM tools finish with a non-zero
-## exit code and an error message on stderr. The test uses llvm-cxxfilt, but
-## it's a logic from the default SIGPIPE handler, so it applies to all the tools.
-## This is required for UNIX03 conformance.
-
-# UNSUPPORTED: system-windows
-
-# RUN: not %python %s llvm-cxxfilt 2>&1 | FileCheck %s
-# CHECK: error: write on a pipe with no reader
-
-import subprocess
-import sys
-
-with subprocess.Popen([sys.argv[1]], stdout=subprocess.PIPE, stdin=subprocess.PIPE) as process:
-  process.stdout.close()
-
-  # llvm-cxxfilt with no extra arguments runs interactively and writes input
-  # to output. Writing continuously to stdin should trigger SIGPIPE when the
-  # subprocess attempts to write out bytes to a closed stdout.
-  try:
-    while True:
-      process.stdin.write("foo\n".encode("utf-8"))
-  except BrokenPipeError:
-    # Clear stdin, pipe is broken and closing it on cleanup will raise an exception.
-    process.stdin = None
-sys.exit(process.returncode)
Index: llvm/lib/Support/Unix/Signals.inc
===================================================================
--- llvm/lib/Support/Unix/Signals.inc
+++ llvm/lib/Support/Unix/Signals.inc
@@ -432,10 +432,6 @@
 }
 
 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: D138244.476266.patch
Type: text/x-patch
Size: 1801 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221118/a481d4d0/attachment.bin>


More information about the llvm-commits mailing list