From nobody Fri May 16 14:56:38 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 4ZzVXQ58rvz5vrQR; Fri, 16 May 2025 14:56:38 +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 4ZzVXQ4R3pz3TnZ; Fri, 16 May 2025 14:56:38 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1747407398; 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=rzxoCJhQpuH/UKJsyI5FaT0DzlA9lSa1KmSPGXhwXqI=; b=K9TTac8nTYygXi/w7YGkUFIF+P9pcr2sUBaW+LhUvWqxbWuMisYs3AEKeCQAxKy0Anju7a ft0Ys9Jcmp5oCMuKZstTXOvZdXPmDbuCh3JJQsSRUoTtrL2MqtBYyj2/aQ/KTMlxKVGTL6 LGv/Ga2XIwPPNo5yzes8z98N2/r8bCT9JVw6hK9wjpT9rASSh/nfi0T98pfUFgydL49CFj LRfF5Dag95RrYKYFtkhLKwONmroppupNVxAMkxZzySIqFvITpBpgIhZ08yjD812Xa0Uvy9 YBEkQTYVE9jfLmMLr+jiVm+Nc9OPAWhMXjymBr4+NxLAE6s33P7nGuO/S/6AZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1747407398; 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=rzxoCJhQpuH/UKJsyI5FaT0DzlA9lSa1KmSPGXhwXqI=; b=s5o+YoGVhUe0IisRk1jvJqmNIfB4B137pdUqs6+Xv4Tr3Xel9L+ASgnSMVlUT4WlvddHde lzeeDVlaxKIO5nhgCPXhQyLKtEQ4STgIwbf/ctP1I9BhSQIP2lmvMfYGF8SjEptVsZQbC6 A9Gb86Hx3Z9MgsQbJu3NRgvPOIfb4HFv4G0Ky+oqAmeI0vyaOL2/0//ic11ZZ0W6/iUK4H oiFaakyB/Lo1Otu4NWzF36eG0FxSROI1EJz41t2jJr3oApKAynvHFKWINCFUTcsOA+kT6s 8OrCeekULatfRv9rk7n39kia+PTE/Yj8Iz4Iu50IhllHXoz7n66ICV7tWp9JBA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1747407398; a=rsa-sha256; cv=none; b=VYj3UHOUXvJsXnb5S8h97FPhuckdOHQKESvKuMorOg+wZH6rr+XPxDLXn3yvPAqIJX4vle NuxPVFITKpOEqssvUu82L6G7ElnBeGNQBa0oBSic6/CzutaToVoFihHCG16BiWcoOwpWDF RmDaVK4yMJmWRODHsdveAF5djA6VMa2U4l1fAxI1+AnECX19fWAFDr705DGv1ovqcwB/PY wsC2+v/PDONJErAbk4CTeWeugZbXAMVZT3nf6jupdSRZGb7uG73CCGvkLw4A0icyxe2nyM eH+1wwoUzXMeszdwXwG9/iZG+S4tNc0RWYzm2KBpHGvv0+dxo+Ppo9ogca1KVg== 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 4ZzVXQ41b9z16tC; Fri, 16 May 2025 14:56:38 +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 54GEucBh015085; Fri, 16 May 2025 14:56:38 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 54GEucs8015082; Fri, 16 May 2025 14:56:38 GMT (envelope-from git) Date: Fri, 16 May 2025 14:56:38 GMT Message-Id: <202505161456.54GEucs8015082@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Dag-Erling =?utf-8?Q?Sm=C3=B8rgrav?= Subject: git: fbaba7aa4322 - main - 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/main X-Git-Reftype: branch X-Git-Commit: fbaba7aa432257a9b787edc6bfdbfbde94f2e0d5 Auto-Submitted: auto-generated The branch main has been updated by des: URL: https://cgit.FreeBSD.org/src/commit/?id=fbaba7aa432257a9b787edc6bfdbfbde94f2e0d5 commit fbaba7aa432257a9b787edc6bfdbfbde94f2e0d5 Author: Dag-Erling Smørgrav AuthorDate: 2025-05-16 14:56:13 +0000 Commit: Dag-Erling Smørgrav CommitDate: 2025-05-16 14:56:25 +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 --- 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 68a4b3a40588..ec20fc813bf4 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 @@ -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} }