summaryrefslogtreecommitdiffstats
path: root/read.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2015-03-17 07:33:07 +0000
committerIngo Schwarze <schwarze@openbsd.org>2015-03-17 07:33:07 +0000
commit27bcceb5c71e31ddc4c21e26e2161fd0b339c3f4 (patch)
tree5e5b45b5163922afec79bccfcf849f966c7fe3cf /read.c
parent45532c8b0d0090977b1e7e839c2340e456a6a6ab (diff)
downloadmandoc-27bcceb5c71e31ddc4c21e26e2161fd0b339c3f4.tar.gz
When the user exits the pager before the pager has drained all input
from man(1), man(1) dies from SIGPIPE. Exiting man(1) is fine in this case, generating more output would be pointless, but without handling SIGPIPE, the exit code from man(1) was wrong and csh(1) printed an ugly message "Broken pipe". Fix this by handling SIGPIPE explicitly. Issue noticed by deraadt@.
Diffstat (limited to 'read.c')
-rw-r--r--read.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/read.c b/read.c
index abad8e0c..511ce45e 100644
--- a/read.c
+++ b/read.c
@@ -29,6 +29,7 @@
#include <ctype.h>
#include <errno.h>
#include <fcntl.h>
+#include <signal.h>
#include <stdarg.h>
#include <stdint.h>
#include <stdio.h>
@@ -846,6 +847,7 @@ mparse_open(struct mparse *curp, int *fd, const char *file)
perror("dup");
exit((int)MANDOCLEVEL_SYSERR);
}
+ signal(SIGPIPE, SIG_DFL);
execlp("gunzip", "gunzip", "-c", file, NULL);
perror("exec");
exit((int)MANDOCLEVEL_SYSERR);