summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBill Wendling <morbo@google.com>2022-11-17 16:07:15 -0800
committerTom Stellard <tstellar@redhat.com>2022-11-23 06:36:25 -0800
commite6e61e9b2ef7c0fa3fe2cd7c612e00ecf57a9dd8 (patch)
tree48a414ea5aa2f55a9abf3391469c6bfbba8525f3
parent25a36ca5c791611588a455e7e7e8a3593e90f9a3 (diff)
downloadllvm-e6e61e9b2ef7c0fa3fe2cd7c612e00ecf57a9dd8.tar.gz
Revert "Reapply: Add an error message to the default SIGPIPE handler"
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, and there's no way to turn this error message off to avoid spurious error messages. UNIX03 apparently doesn't require printing an error message on SIGPIPE, but specifically when there's an error on the stdout stream in a normal program flow, e.g. when SIGPIPE trap is disabled. A separate patch is planned to address the specific case we care most about (involving llvm-nm). This reverts commit b89bcefa6202e310eb3167dd1c37f1807377ec8d. Link: https://github.com/llvm/llvm-project/issues/59037 Link: https://github.com/ClangBuiltLinux/linux/issues/1651 Differential Revision: https://reviews.llvm.org/D138244 (cherry picked from commit 4787efa38066adb51e2c049499d25b3610c0877b)
-rw-r--r--llvm/lib/Support/Unix/Signals.inc4
-rw-r--r--llvm/test/Support/unix03-sigpipe-exit.test26
2 files changed, 0 insertions, 30 deletions
diff --git a/llvm/lib/Support/Unix/Signals.inc b/llvm/lib/Support/Unix/Signals.inc
index bf145bffe8bf..23ac012b9e00 100644
--- a/llvm/lib/Support/Unix/Signals.inc
+++ b/llvm/lib/Support/Unix/Signals.inc
@@ -432,10 +432,6 @@ void llvm::sys::SetOneShotPipeSignalFunction(void (*Handler)()) {
}
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);
}
diff --git a/llvm/test/Support/unix03-sigpipe-exit.test b/llvm/test/Support/unix03-sigpipe-exit.test
deleted file mode 100644
index 01680841db00..000000000000
--- a/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)