diff options
author | Ron Yorston <rmy@pobox.com> | 2018-12-11 15:52:31 +0000 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2018-12-11 15:52:31 +0000 |
commit | 68ddd4ec3c1275c66e01172498055817cbb10f04 (patch) | |
tree | e31826ae839535bef102a7ad61bc0e029b20ffae /include | |
parent | 6c3fd20e67cab2331b1e862c03eeb95a70625454 (diff) | |
download | busybox-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 'include')
-rw-r--r-- | include/libbb.h | 2 | ||||
-rw-r--r-- | include/mingw.h | 4 |
2 files changed, 4 insertions, 2 deletions
diff --git a/include/libbb.h b/include/libbb.h index 4ac749fd3..a17da9c1f 100644 --- a/include/libbb.h +++ b/include/libbb.h | |||
@@ -536,9 +536,7 @@ enum { | |||
536 | #endif | 536 | #endif |
537 | + (1LL << SIGINT) | 537 | + (1LL << SIGINT) |
538 | + (1LL << SIGTERM) | 538 | + (1LL << SIGTERM) |
539 | #ifdef SIGPIPE | ||
540 | + (1LL << SIGPIPE) // Write to pipe with no readers | 539 | + (1LL << SIGPIPE) // Write to pipe with no readers |
541 | #endif | ||
542 | #ifdef SIGQUIT | 540 | #ifdef SIGQUIT |
543 | + (1LL << SIGQUIT) // Quit from keyboard | 541 | + (1LL << SIGQUIT) // Quit from keyboard |
544 | #endif | 542 | #endif |
diff --git a/include/mingw.h b/include/mingw.h index a1869227d..8a695d2d2 100644 --- a/include/mingw.h +++ b/include/mingw.h | |||
@@ -93,10 +93,14 @@ IMPL(getpwent,struct passwd *,NULL,void) | |||
93 | * signal.h | 93 | * signal.h |
94 | */ | 94 | */ |
95 | #define SIGKILL 9 | 95 | #define SIGKILL 9 |
96 | #define SIGPIPE 13 | ||
96 | 97 | ||
97 | #define SIG_UNBLOCK 1 | 98 | #define SIG_UNBLOCK 1 |
98 | 99 | ||
99 | NOIMPL(FAST_FUNC sigprocmask_allsigs, int how UNUSED_PARAM); | 100 | NOIMPL(FAST_FUNC sigprocmask_allsigs, int how UNUSED_PARAM); |
101 | typedef void (*sighandler_t)(int); | ||
102 | sighandler_t winansi_signal(int signum, sighandler_t handler); | ||
103 | #define signal(s, h) winansi_signal(s, h) | ||
100 | 104 | ||
101 | /* | 105 | /* |
102 | * stdio.h | 106 | * stdio.h |