From nobody Wed May 21 17:37:25 2025 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4b2dsd3Ptgz5wG1D; Wed, 21 May 2025 17:37:25 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4b2dsd2n7Jz40MM; Wed, 21 May 2025 17:37:25 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1747849045; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=W05DzhiaZBLVtGztCxl1HKRpLB0Qncry8X/dtsj1Ao4=; b=nVnRggcbP+RlGTYH8a4MI0S2qwzoCmzKZWG7vOFDVqP/Qq8ZGConWWaqZsgCDUzxRqkaG7 5W2oha6cNccak/RHx7j0eVy9praoJi5wADnoGVthpLGZl0gHSQOewso80s7Cbmd5FMLCYt Px8pQxi3jjzJxmB7zzsdbYpJjNEtwpUidp0WSoewlIyX6PabAW4cK3PZN1qSbbAMds727S iJwC5I7PhAukGFwV0zo3eekLLgmfbrmHM/iSbppla1gOTSVhxWTGpAUl5aTi8VfVbPF3KZ b2MYiiH6D0BDJLYF2y48iF/bbpbjdAZgYhe4EAZEJi5N2+93jn+BzkloQEDfkg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1747849045; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=W05DzhiaZBLVtGztCxl1HKRpLB0Qncry8X/dtsj1Ao4=; b=VxVdpZBa9AJPe07pwNbcLiSpBdVAminQK2XPltwPGnjia2VyEs9raz0Jy3C0uNNK8BMw9k WUefHxBADEQugcan2QtMTnt9Un2qZTvqaxriklBNiRpeA/gtCWPuI0FyDOf0TinjhS9j25 3FrYNR/yhYEcWBPRfC7Y71iCY5fgA0uSeETFW3MUzVLQGedMDfXOR4l1jZYtXLHXDdg1ra JSDpPcanXIhcuRRBmUCZ+5Z8BwUX0MC6hvW0amIFzUaYydXBA9bVr5M+S6kbqMGbXl7X+c ffeZI0hHs1KW4D065UzqbaaJ4WTNVNAvKpUJRwke5FGv9BfDwEq++gOeO5uxlg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1747849045; a=rsa-sha256; cv=none; b=ULRZSSeuVYjU/gac/7VjG3u1EiWR/VwZXH0eQtjDtt7J97XP1W2f9RsDN2oWXXuhBoyne1 afwgeGsw1fc/meqf3YRrQfe+vAn2oLO5oeZ7PvAwSquihjIwFTa/E8RWFoEtzYnz98bVPP fLzyTlo7gdlp/RRZX6jQAnDjzeFUR9fAeKFEd3kHwWsOtpqxqZrjJoy9pFJJ5Itm3yEYgp bhK1ZehIply+UoX/uRzythRKnU5HGhZ+QqXboCGy0bZsOpC9Vq/DSRUlps1D/6KTgMxyfN 6LyAWWcklmhpuFOHgAbCwbVE9b9MD2DY6zUSFJFqwyKUllmup2ALWg+ZXEZozA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4b2dsd2H99zlDQ; Wed, 21 May 2025 17:37:25 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 54LHbP1o056479; Wed, 21 May 2025 17:37:25 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 54LHbPMU056476; Wed, 21 May 2025 17:37:25 GMT (envelope-from git) Date: Wed, 21 May 2025 17:37:25 GMT Message-Id: <202505211737.54LHbPMU056476@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Dag-Erling =?utf-8?Q?Sm=C3=B8rgrav?= Subject: git: 84b971c9186a - releng/14.3 - man: Exit cleanly on SIGPIPE. List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: des X-Git-Repository: src X-Git-Refname: refs/heads/releng/14.3 X-Git-Reftype: branch X-Git-Commit: 84b971c9186ad241151a84bbbfb9218adc54df6c Auto-Submitted: auto-generated The branch releng/14.3 has been updated by des: URL: https://cgit.FreeBSD.org/src/commit/?id=84b971c9186ad241151a84bbbfb9218adc54df6c commit 84b971c9186ad241151a84bbbfb9218adc54df6c Author: Dag-Erling Smørgrav AuthorDate: 2025-05-16 14:56:13 +0000 Commit: Dag-Erling Smørgrav CommitDate: 2025-05-21 17:36:41 +0000 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. Approved by: re (cperciva) PR: 223516, 279542 Fixes: 14a5c1068d37, a85d870007e7 MFC after: 1 week Reviewed by: ziaee, kevans Differential Revision: https://reviews.freebsd.org/D50302 (cherry picked from commit fbaba7aa432257a9b787edc6bfdbfbde94f2e0d5) (cherry picked from commit 2f99190a9234b119bcec1e4645e87d4e6016e5a5) --- usr.bin/man/man.sh | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/usr.bin/man/man.sh b/usr.bin/man/man.sh index 341a57c6d7dc..b1cfc6c41752 100755 --- a/usr.bin/man/man.sh +++ b/usr.bin/man/man.sh @@ -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 @@ -1055,6 +1058,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} }