mirror of
https://git.freebsd.org/src.git
synced 2026-01-16 23:02:24 +00:00
man: Exit cleanly on SIGPIPE.
The first attempt at addressing this simply suppressed SIGPIPE, which resulted in mandoc printing out error messages instead. This was then reverted, but the pipefail was (correctly) left in, so man still returned a nonzero exit code if you quit a page before the end. PR: 223516, 279542 Fixes:14a5c1068d,a85d870007MFC after: 1 week Reviewed by: ziaee, kevans Differential Revision: https://reviews.freebsd.org/D50302
This commit is contained in:
parent
9d29fc2e4b
commit
fbaba7aa43
1 changed files with 14 additions and 1 deletions
|
|
@ -33,7 +33,10 @@
|
|||
# it is better to terminate it.
|
||||
ulimit -t 20
|
||||
|
||||
# do not ignore the exit status of roff tools
|
||||
# Do not ignore the exit codes of roff tools, as they may indicate a
|
||||
# problem with the page being rendered. Note that this also causes a
|
||||
# nonzero exit when the user quits reading before reaching the end, so
|
||||
# we need to look out for and deal with that specific case.
|
||||
set -o pipefail
|
||||
|
||||
# Usage: add_to_manpath path
|
||||
|
|
@ -1061,6 +1064,16 @@ do_man() {
|
|||
man_find_and_display "$page"
|
||||
done
|
||||
|
||||
# The user will very commonly quit reading the page before
|
||||
# reaching the bottom. Depending on the length of the page
|
||||
# and the pager's buffer size, this may result in a SIGPIPE.
|
||||
# This is normal, so convert that exit code to zero.
|
||||
if [ ${ret:-0} -gt 128 ]; then
|
||||
if [ "$(kill -l "${ret}")" = "PIPE" ]; then
|
||||
ret=0
|
||||
fi
|
||||
fi
|
||||
|
||||
exit ${ret:-0}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue