From nobody Wed May 21 16:57:39 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 4b2czl3LZnz5wCLQ; Wed, 21 May 2025 16:57:39 +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 4b2czl2vlLz3dC8; Wed, 21 May 2025 16:57:39 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1747846659; 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=vfKtJ3J1m+vhNANw5nKfokkENMUCXhL3LJhtJjTifXY=; b=sq8HC45GBKNnVAQwyVYrHMgVqY/UNFfr4RaSFVOYbW5eITPTnW/oj/wuz/7p+WVZIuLLE9 6s1LfS9NOCDfBf75cZgTooBOvyCGObWbI1wAU4M+VmcopxiiOk/4v/6mapkzhJRo5JlPZV 6lC6pnxZls8z4EnRjK+1SNrLYfILyJ+x0YIBfEih7k0UQZbd5iYPx0K7liEbE3116IL8gp Lv7ztLQRq9ZoL0icv+fhuJnWZPF/KUuC6lRSigT1nbpAQb9tz20ictU/e8M//EAoYyUwod yOuvyRGdZvY8SadPFTzg/y2orVw+eQNeyQkeFyvSklVq15A0yo6ucV1+WcoqrA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1747846659; 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=vfKtJ3J1m+vhNANw5nKfokkENMUCXhL3LJhtJjTifXY=; b=LhLHwBpMr8HGI9j++xSsKNceESd0Bd5dtw+TkS9sGAEMXUaG8W7AeponC6E+IH8Od2F640 DIyObdKVHCt/9dgxc3uCISSDKbN+y+qEZKvS7h/BLuoqRW8L14rAUQaEJ4giIOPknkDBzA Oi9Su+m6GD3bAqEfsSdB+On2ON3Tpzq6F090Z3+Ib1wMifvl6a9gP39GYfD0Z81FhryKRk AHzNhIWZEhoezutqWmwxrbfoUIM/om6q6a8xhfX25W2eNtJ9s3/QrrdP8rtqd9dhUTsss2 DIWXqLFjeCfuBEiwxx7JrLk/pKMv3pzIsPd0IdhAZ5ppqcjRmHHb3KYa0E01fg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1747846659; a=rsa-sha256; cv=none; b=Xon6V80Yb3yD55Z6iPYyxHfotN5DQM6j5vKnylZ4zpqUlhUymmUfwr0FSFA/RBdR/e9St4 gG2NhSlzhCKuhohMoH/g819zKOscqlpzONs/RVaQaZBuLDguESiPNKf3++oo9b3EY87POD mFgzwFYtjQfeO/OXT1kxpyV1YO4Vz+Lr6dZBItHr6qc7BobYAQO76biIuh/806C8WE/WFD GHg5a4fxtgeXmaz6rgATkz8Ke2YWoeoIsNuKcWbOIL4yaUImI6pI3T9xlQHoI3h6GIuc6u WpZn/rkMbNpKeRysQzYcV0RGBCYECAqr/vepd/Jr91+ynhQWjKstqefVZMBK/Q== 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 4b2czl2L6BzjlZ; Wed, 21 May 2025 16:57:39 +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 54LGvdjC080413; Wed, 21 May 2025 16:57:39 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 54LGvdG3080410; Wed, 21 May 2025 16:57:39 GMT (envelope-from git) Date: Wed, 21 May 2025 16:57:39 GMT Message-Id: <202505211657.54LGvdG3080410@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: 2f99190a9234 - stable/14 - 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/stable/14 X-Git-Reftype: branch X-Git-Commit: 2f99190a9234b119bcec1e4645e87d4e6016e5a5 Auto-Submitted: auto-generated The branch stable/14 has been updated by des: URL: https://cgit.FreeBSD.org/src/commit/?id=2f99190a9234b119bcec1e4645e87d4e6016e5a5 commit 2f99190a9234b119bcec1e4645e87d4e6016e5a5 Author: Dag-Erling Smørgrav AuthorDate: 2025-05-16 14:56:13 +0000 Commit: Dag-Erling Smørgrav CommitDate: 2025-05-21 16:55:37 +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. 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) --- 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} }