aboutsummaryrefslogtreecommitdiff
path: root/coreutils
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2018-12-11 15:52:31 +0000
committerRon Yorston <rmy@pobox.com>2018-12-11 15:52:31 +0000
commit68ddd4ec3c1275c66e01172498055817cbb10f04 (patch)
treee31826ae839535bef102a7ad61bc0e029b20ffae /coreutils
parent6c3fd20e67cab2331b1e862c03eeb95a70625454 (diff)
downloadbusybox-w32-68ddd4ec3c1275c66e01172498055817cbb10f04.tar.gz
busybox-w32-68ddd4ec3c1275c66e01172498055817cbb10f04.tar.bz2
busybox-w32-68ddd4ec3c1275c66e01172498055817cbb10f04.zip
win32: emulate SIGPIPE
The code to check whether a write error is due to a broken pipe can now either: - return with error EPIPE; - cause the process to exit with code 128+SIGPIPE. The default is the latter but the behaviour can be changed by issuing signal(SIGPIPE, SIG_IGN) and signal(SIGPIPE, SIG_DFL) calls. No actual signal is involved so kill can't send SIGPIPE and handlers other than SIG_IGN and SIG_DFL aren't supported. This does, however, avoid unsightly 'broken pipe' errors from commands like the example in GitHub issue #99: dd if=/dev/urandom | tr -dc _A-Z-a-z-0-9 | head -c${1:-32};echo;
Diffstat (limited to 'coreutils')
-rw-r--r--coreutils/tee.c2
1 files changed, 0 insertions, 2 deletions
diff --git a/coreutils/tee.c b/coreutils/tee.c
index d0ded58c4..f0ec791bb 100644
--- a/coreutils/tee.c
+++ b/coreutils/tee.c
@@ -69,11 +69,9 @@ int tee_main(int argc, char **argv)
69 signal(SIGINT, SIG_IGN); /* TODO - switch to sigaction. (why?) */ 69 signal(SIGINT, SIG_IGN); /* TODO - switch to sigaction. (why?) */
70 } 70 }
71 retval = EXIT_SUCCESS; 71 retval = EXIT_SUCCESS;
72#ifdef SIGPIPE
73 /* gnu tee ignores SIGPIPE in case one of the output files is a pipe 72 /* gnu tee ignores SIGPIPE in case one of the output files is a pipe
74 * that doesn't consume all its input. Good idea... */ 73 * that doesn't consume all its input. Good idea... */
75 signal(SIGPIPE, SIG_IGN); 74 signal(SIGPIPE, SIG_IGN);
76#endif
77 75
78 /* Allocate an array of FILE *'s, with one extra for a sentinel. */ 76 /* Allocate an array of FILE *'s, with one extra for a sentinel. */
79 fp = files = xzalloc(sizeof(FILE *) * (argc + 2)); 77 fp = files = xzalloc(sizeof(FILE *) * (argc + 2));