From unknown Sun Jun 15 01:09:57 2025 X-Loop: help-debbugs@gnu.org Subject: bug#34488: Add sort --limit, or document workarounds for sort|head error messages Resent-From: =?UTF-8?Q?=E7=A9=8D=E4=B8=B9=E5=B0=BC?= Dan Jacobson Original-Sender: "Debbugs-submit" Resent-CC: bug-coreutils@gnu.org Resent-Date: Fri, 15 Feb 2019 14:53:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 34488 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: To: 34488@debbugs.gnu.org X-Debbugs-Original-To: bug-coreutils@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.155024236632643 (code B ref -1); Fri, 15 Feb 2019 14:53:01 +0000 Received: (at submit) by debbugs.gnu.org; 15 Feb 2019 14:52:46 +0000 Received: from localhost ([127.0.0.1]:48716 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1guer8-0008UQ-Co for submit@debbugs.gnu.org; Fri, 15 Feb 2019 09:52:46 -0500 Received: from eggs.gnu.org ([209.51.188.92]:48613) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1guer6-0008UC-2b for submit@debbugs.gnu.org; Fri, 15 Feb 2019 09:52:45 -0500 Received: from lists.gnu.org ([209.51.188.17]:52908) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gueqt-0002Af-WE for submit@debbugs.gnu.org; Fri, 15 Feb 2019 09:52:34 -0500 Received: from eggs.gnu.org ([209.51.188.92]:34754) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gueqt-0007fz-AR for bug-coreutils@gnu.org; Fri, 15 Feb 2019 09:52:31 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: * X-Spam-Status: No, score=1.8 required=5.0 tests=BAYES_50,FROM_EXCESS_BASE64, RCVD_IN_DNSWL_NONE,URIBL_BLOCKED autolearn=disabled version=3.3.2 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gueqm-000221-2N for bug-coreutils@gnu.org; Fri, 15 Feb 2019 09:52:26 -0500 Received: from quail.birch.relay.mailchannels.net ([23.83.209.151]:46519) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gueql-0001uO-BO for bug-coreutils@gnu.org; Fri, 15 Feb 2019 09:52:23 -0500 X-Sender-Id: dreamhost|x-authsender|jidanni@jidanni.org Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id 1932342F1C for ; Fri, 15 Feb 2019 14:52:19 +0000 (UTC) Received: from pdx1-sub0-mail-a80.g.dreamhost.com (unknown [100.96.20.98]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id CA72E4288B for ; Fri, 15 Feb 2019 14:52:18 +0000 (UTC) X-Sender-Id: dreamhost|x-authsender|jidanni@jidanni.org Received: from pdx1-sub0-mail-a80.g.dreamhost.com (pop.dreamhost.com [64.90.62.162]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384) by 0.0.0.0:2500 (trex/5.16.2); Fri, 15 Feb 2019 14:52:19 +0000 X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|jidanni@jidanni.org X-MailChannels-Auth-Id: dreamhost X-Whispering-Society: 469c91511bc5f22c_1550242338966_1519023981 X-MC-Loop-Signature: 1550242338966:315708415 X-MC-Ingress-Time: 1550242338966 Received: from pdx1-sub0-mail-a80.g.dreamhost.com (localhost [127.0.0.1]) by pdx1-sub0-mail-a80.g.dreamhost.com (Postfix) with ESMTP id 72429807C4 for ; Fri, 15 Feb 2019 06:52:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=jidanni.org; h=from:to :subject:date:message-id:mime-version:content-type; s= jidanni.org; bh=ICt1kx/Acdo84qqPCnbHqUDfxIQ=; b=A/4Do0bzrEwsa4fq R+aS0/cjJdar3OLzeJm32bFfRgqIR1+90dchSmeW9EypHIxJIPGXFTC31+XX0p8M /TlW1/PPWE+sexcjsudIsnKN1or1F6EGW/DKnXV9Sy4rgSg4wvIBKQsWsHhDIwDm tfiuBGKj5PFge5N7n5DnUOGu5bQ= Received: from jidanni.org (114-41-34-44.dynamic-ip.hinet.net [114.41.34.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: jidanni@jidanni.org) by pdx1-sub0-mail-a80.g.dreamhost.com (Postfix) with ESMTPSA id D9E48807BC for ; Fri, 15 Feb 2019 06:52:17 -0800 (PST) X-DH-BACKEND: pdx1-sub0-mail-a80 From: =?UTF-8?Q?=E7=A9=8D=E4=B8=B9=E5=B0=BC?= Dan Jacobson Date: Fri, 15 Feb 2019 22:43:48 +0800 Message-ID: <87mumxf6xn.fsf@jidanni.org> MIME-Version: 1.0 Content-Type: text/plain X-VR-OUT-STATUS: OK X-VR-OUT-SCORE: 0 X-VR-OUT-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedtledruddtjedgieelucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuggftfghnshhusghstghrihgsvgdpffftgfetoffjqffuvfenuceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufffkgggtsehttdertddttdejnecuhfhrohhmpejnnjjnucffrghnucflrggtohgsshhonhcuoehjihgurghnnhhisehjihgurghnnhhirdhorhhgqeenucfkphepuddugedrgedurdefgedrgeegnecurfgrrhgrmhepmhhouggvpehsmhhtphdphhgvlhhopehjihgurghnnhhirdhorhhgpdhinhgvthepuddugedrgedurdefgedrgeegpdhrvghtuhhrnhdqphgrthhhpeeprehuthhfqdekreeureehiehmpfehnfhiheehsgevkeerpecuffgrnhculfgrtghosghsohhnuceojhhiuggrnhhnihesjhhiuggrnhhnihdrohhrgheqpdhmrghilhhfrhhomhepjhhiuggrnhhnihesjhhiuggrnhhnihdrohhrghdpnhhrtghpthhtohepsghughdqtghorhgvuhhtihhlshesghhnuhdrohhrghenucevlhhushhtvghrufhiiigvpedt X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 23.83.209.151 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Spam-Score: 1.0 (+) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.0 (/) Things start out cheery, but quickly get ugly, $ for i in 9 99 999 9999 99999; do seq $i|sort -n|sed 5q|wc -l; done 5 5 5 5 sort: write failed: 'standard output': Broken pipe sort: write error 5 sort: write failed: 'standard output': Broken pipe sort: write error Therefore, kindly add a sort --limit=n, and/or on (info "(coreutils) sort invocation") admit the problem, and give some workarounds, lest our scripts occasionally spew error messages seemingly randomly, just when the boss is looking. And no fair saying "just save the output" (could be big) "into a file first, and do head(1) or sed(1) on that." From unknown Sun Jun 15 01:09:57 2025 X-Loop: help-debbugs@gnu.org Subject: bug#34488: Add sort --limit, or document workarounds for sort|head error messages Resent-From: Eric Blake Original-Sender: "Debbugs-submit" Resent-CC: bug-coreutils@gnu.org Resent-Date: Fri, 15 Feb 2019 15:22:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 34488 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: To: =?UTF-8?Q?=E7=A9=8D=E4=B8=B9=E5=B0=BC?= Dan Jacobson , 34488@debbugs.gnu.org Received: via spool by 34488-submit@debbugs.gnu.org id=B34488.155024406811622 (code B ref 34488); Fri, 15 Feb 2019 15:22:02 +0000 Received: (at 34488) by debbugs.gnu.org; 15 Feb 2019 15:21:08 +0000 Received: from localhost ([127.0.0.1]:49686 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gufIa-00031N-1f for submit@debbugs.gnu.org; Fri, 15 Feb 2019 10:21:08 -0500 Received: from mx1.redhat.com ([209.132.183.28]:34558) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gufIX-00030Y-LI for 34488@debbugs.gnu.org; Fri, 15 Feb 2019 10:21:06 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E8437317DD; Fri, 15 Feb 2019 15:20:59 +0000 (UTC) Received: from [10.3.116.127] (ovpn-116-127.phx2.redhat.com [10.3.116.127]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 97B16600C5; Fri, 15 Feb 2019 15:20:59 +0000 (UTC) References: <87mumxf6xn.fsf@jidanni.org> From: Eric Blake Openpgp: preference=signencrypt Autocrypt: addr=eblake@redhat.com; keydata= xsBNBEvHyWwBCACw7DwsQIh0kAbUXyqhfiKAKOTVu6OiMGffw2w90Ggrp4bdVKmCaEXlrVLU xphBM8mb+wsFkU+pq9YR621WXo9REYVIl0FxKeQo9dyQBZ/XvmUMka4NOmHtFg74nvkpJFCD TUNzmqfcjdKhfFV0d7P/ixKQeZr2WP1xMcjmAQY5YvQ2lUoHP43m8TtpB1LkjyYBCodd+LkV GmCx2Bop1LSblbvbrOm2bKpZdBPjncRNob73eTpIXEutvEaHH72LzpzksfcKM+M18cyRH+nP sAd98xIbVjm3Jm4k4d5oQyE2HwOur+trk2EcxTgdp17QapuWPwMfhaNq3runaX7x34zhABEB AAHNHkVyaWMgQmxha2UgPGVibGFrZUByZWRoYXQuY29tPsLAegQTAQgAJAIbAwULCQgHAwUV CgkICwUWAgMBAAIeAQIXgAUCS8fL9QIZAQAKCRCnoWtKJSdDahBHCACbl/5FGkUqJ89GAjeX RjpAeJtdKhujir0iS4CMSIng7fCiGZ0fNJCpL5RpViSo03Q7l37ss+No+dJI8KtAp6ID+PMz wTJe5Egtv/KGUKSDvOLYJ9WIIbftEObekP+GBpWP2+KbpADsc7EsNd70sYxExD3liwVJYqLc Rw7so1PEIFp+Ni9A1DrBR5NaJBnno2PHzHPTS9nmZVYm/4I32qkLXOcdX0XElO8VPDoVobG6 gELf4v/vIImdmxLh/w5WctUpBhWWIfQDvSOW2VZDOihm7pzhQodr3QP/GDLfpK6wI7exeu3P pfPtqwa06s1pae3ad13mZGzkBdNKs1HEm8x6zsBNBEvHyWwBCADGkMFzFjmmyqAEn5D+Mt4P zPdO8NatsDw8Qit3Rmzu+kUygxyYbz52ZO40WUu7EgQ5kDTOeRPnTOd7awWDQcl1gGBXgrkR pAlQ0l0ReO57Q0eglFydLMi5bkwYhfY+TwDPMh3aOP5qBXkm4qIYSsxb8A+i00P72AqFb9Q7 3weG/flxSPApLYQE5qWGSXjOkXJv42NGS6o6gd4RmD6Ap5e8ACo1lSMPfTpGzXlt4aRkBfvb NCfNsQikLZzFYDLbQgKBA33BDeV6vNJ9Cj0SgEGOkYyed4I6AbU0kIy1hHAm1r6+sAnEdIKj cHi3xWH/UPrZW5flM8Kqo14OTDkI9EtlABEBAAHCwF8EGAEIAAkFAkvHyWwCGwwACgkQp6Fr SiUnQ2q03wgAmRFGDeXzc58NX0NrDijUu0zx3Lns/qZ9VrkSWbNZBFjpWKaeL1fdVeE4TDGm I5mRRIsStjQzc2R9b+2VBUhlAqY1nAiBDv0Qnt+9cLiuEICeUwlyl42YdwpmY0ELcy5+u6wz mK/jxrYOpzXKDwLq5k4X+hmGuSNWWAN3gHiJqmJZPkhFPUIozZUCeEc76pS/IUN72NfprZmF Dp6/QDjDFtfS39bHSWXKVZUbqaMPqlj/z6Ugk027/3GUjHHr8WkeL1ezWepYDY7WSoXwfoAL 2UXYsMAr/uUncSKlfjvArhsej0S4zbqim2ZY6S8aRWw94J3bSvJR+Nwbs34GPTD4Pg== Organization: Red Hat, Inc. Message-ID: <49916778-4758-d040-5fcc-6e277a2dc183@redhat.com> Date: Fri, 15 Feb 2019 09:20:58 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.4.0 MIME-Version: 1.0 In-Reply-To: <87mumxf6xn.fsf@jidanni.org> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="JHhWxgwFnb8myrHYZaOUjWkR4hybfzWCi" X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Fri, 15 Feb 2019 15:20:59 +0000 (UTC) X-Spam-Score: -5.0 (-----) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -6.0 (------) This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --JHhWxgwFnb8myrHYZaOUjWkR4hybfzWCi Content-Type: multipart/mixed; boundary="2xmsTPVM6ViDlWWq2wvazDkkAe26lCY7I"; protected-headers="v1" From: Eric Blake To: =?UTF-8?B?56mN5Li55bC8IERhbiBKYWNvYnNvbg==?= , 34488@debbugs.gnu.org Message-ID: <49916778-4758-d040-5fcc-6e277a2dc183@redhat.com> Subject: Re: bug#34488: Add sort --limit, or document workarounds for sort|head error messages References: <87mumxf6xn.fsf@jidanni.org> In-Reply-To: <87mumxf6xn.fsf@jidanni.org> --2xmsTPVM6ViDlWWq2wvazDkkAe26lCY7I Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: quoted-printable On 2/15/19 8:43 AM, =E7=A9=8D=E4=B8=B9=E5=B0=BC Dan Jacobson wrote: > Things start out cheery, but quickly get ugly, >=20 > $ for i in 9 99 999 9999 99999; do seq $i|sort -n|sed 5q|wc -l; done > 5 > 5 > 5 > 5 > sort: write failed: 'standard output': Broken pipe > sort: write error > 5 > sort: write failed: 'standard output': Broken pipe > sort: write error Your code is demonstrating what happens when sed ends processing without consuming all of sort's output, to the point that sort is producing more output than what stdio can buffer, and thus with enough pending output will trigger a situation of SIGPIPE - but when SIGPIPE is ignored, that instead turns into an EPIPE failure to write(), and sort treats all write() failures as worthy of error reporting. If you want sort to die silently, then don't ignore SIGPIPE, so that sort won't see EPIPE and thus won't be noisy. $ (trap '' PIPE; seq 9999 | sort -n | sed 5q | wc -l) 5 sort: write failed: 'standard output': Broken pipe sort: write error $ (trap - PIPE; seq 9999 | sort -n | sed 5q | wc -l) 5 Except that POSIX has the nasty requirement that sh started with an inherited ignored SIGPIPE must silently ignore all attempts from within the shell to restore SIGPIPE handling to child processes of the shell: $ (trap '' PIPE; bash -c 'trap - PIPE; \ seq 9999 | sort -n | sed 5q | wc -l') 5 sort: write failed: 'standard output': Broken pipe sort: write error And unfortunately, there are several common cases of badly-behaved environment setups that leave SIGPIPE ignored in the child (for example, a quick google search found this: https://blog.nelhage.com/2010/02/a-very-subtle-bug/) You HAVE to use some other intermediate program if you want to override an inherited ignored SIGPIPE in sh into an inherited default-behavior SIGPIPE in sort. Perhaps coreutils should teach 'env' a command-line option to forcefully reset SIGPIPE back to default behavior (or add a new coreutil that does the same idea), as a way to work around POSIX' requirement on sh. If we did that, then even if your sh is started with SIGPIPE ignored (so that the shell itself can't restore default behavior), you could do this theoretical invocation: $ seq 9999 | env --default-signal PIPE sort -n | sed 5q | wc -l 5 and avoid the EPIPE failures because sort is forced to start with SIGPIPE handling rather than ignored. >=20 > Therefore, kindly add a sort --limit=3Dn, Not scalable. The problem you encountered is NOT the fault of sort, but is common to ALL utilities which dutifully report write() failures on EPIPE errors, which in turn happens when SIGPIPE is ignored. Adding an option to every such utility that produces outtput is not a good use of time. If you want to change things universally, perhaps you should petition POSIX to change the requirements to allow applications the option to silently exit without an error message on EPIPE failures to write(), instead of the current wording that all write() errors must be diagnosed. > and/or on (info "(coreutils) sort invocation") > admit the problem, and give some workarounds, lest > our scripts occasionally spew error messages seemingly randomly, > just when the boss is looking. The problem is not in sort, but in the fact that your environment is ignoring SIGPIPE. Documenting something in sort doesn't scale, but perhaps the documentation could mention SIGPIPE considerations in a more global chapter covering all of the coreutils. >=20 > And no fair saying "just save the output" (could be big) "into a file > first, and do head(1) or sed(1) on that." >=20 If you have an app that exits noisily on write failures to an early-exit pipe, your solutions are to quit ignoring SIGPIPE, or to change the pipeline to consume all of the output instead of exiting early and causing write failure. --=20 Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3226 Virtualization: qemu.org | libvirt.org --2xmsTPVM6ViDlWWq2wvazDkkAe26lCY7I-- --JHhWxgwFnb8myrHYZaOUjWkR4hybfzWCi Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAEBCAAdFiEEccLMIrHEYCkn0vOqp6FrSiUnQ2oFAlxm2NoACgkQp6FrSiUn Q2o09wgAmb7NlW7yGwrkWaDqjcp0FkzjFr+jLA8KSf8V6qO14emxry9erMnwe3PV SiWDLH6vpu7jtt9cYVA4ju+0Rkj6xCXucoOiBOn/tp9H4uwMmkbA/t0hwtsx9snJ ZBJwTd2xThbmZK5M3FX0uHy46K75SxbALXIb30nrjUA90atJ/a4sybqDQ1oPZxy4 mdZ6y+fz2TRZ4PWTr+Tc+1THqkFXwziWIQOkXR7bApPXBPIeTRAz1isYvBTS3A3t rXwyVVwboBG74l3QhZBfVWZCv7j1EPVUXWDQrSzvljn/xjeoNGUCPt900PzJaMMU wRJ7QFcz3mP0klJxUMKPf2onAtYwgw== =o01o -----END PGP SIGNATURE----- --JHhWxgwFnb8myrHYZaOUjWkR4hybfzWCi-- From unknown Sun Jun 15 01:09:57 2025 X-Loop: help-debbugs@gnu.org Subject: bug#34488: Add sort --limit, or document workarounds for sort|head error messages Resent-From: Assaf Gordon Original-Sender: "Debbugs-submit" Resent-CC: bug-coreutils@gnu.org Resent-Date: Fri, 15 Feb 2019 15:38:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 34488 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: To: =?UTF-8?Q?=E7=A9=8D=E4=B8=B9=E5=B0=BC?= Dan Jacobson , 34488@debbugs.gnu.org Received: via spool by 34488-submit@debbugs.gnu.org id=B34488.155024508113192 (code B ref 34488); Fri, 15 Feb 2019 15:38:02 +0000 Received: (at 34488) by debbugs.gnu.org; 15 Feb 2019 15:38:01 +0000 Received: from localhost ([127.0.0.1]:49691 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gufYt-0003Qa-Mj for submit@debbugs.gnu.org; Fri, 15 Feb 2019 10:38:01 -0500 Received: from mail-pg1-f195.google.com ([209.85.215.195]:40393) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gufYr-0003QM-Nc for 34488@debbugs.gnu.org; Fri, 15 Feb 2019 10:37:58 -0500 Received: by mail-pg1-f195.google.com with SMTP id u9so1442672pgo.7 for <34488@debbugs.gnu.org>; Fri, 15 Feb 2019 07:37:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language:content-transfer-encoding; bh=IAF4Z/gzYVQ/YQVu2yE1+46Peuj2OX998vav4wcoq7Y=; b=NeZQtbaA2paYAeFhFTN4cliNB66gIhjCP2Ckz4W1b+k6RUJCOVZyvNIyn9J1Glx7rt Noyv7YdZRN7TUqlsNOduatLTcS0M9dCV2bnwKS0KSjW0T31vw+LgQDjJ0SJGges7vaWb sI9bjORFIUfp3fh2NCXBgVcGKdOEjZCj4mFBQiCQLioO6EoneU/iQMn/kMDi30PH4Wmh 4KrIhWq5b/5kfnSUvWLwStpTNCMR6+pc801kO8EHyr5+c3yqepqGWmQt23l+6g/dlOAB TseRBsp2NATY0QI0oYsrMGLuT4A1f1aw3YlXPSf6mHPq5Zh7mF8p30VRhnAXgDkyHuX2 5nrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=IAF4Z/gzYVQ/YQVu2yE1+46Peuj2OX998vav4wcoq7Y=; b=JZEWXL7FHnL0iiY3bizsBPfRNIc/p2r3v5xa8dzPoC71CzTrA3F/17rsRSuqtA6Wkh hb9G0o+YTtgTJcoX+9cSlCmlW9bBx6ZFHemX0TFGenbEOETxV12swuTQYoL2oMnsMrjc +4uzRjVipAzNS4KiU3lUXS2C9PGq3fVhZ0x7XBmg3Mmow9EBny1LZE3dBQN6WDyJkuuT imFYm+kmAKnBhhEzyo1DW7C4jqzJy771jCeGnk44UC/fvsFRwpaAgt5fMzLT+xvV2tsq ASnxY3PwzZzb705t7gH9QMvXqVeWZYFcVg5f+hPslSindF1zibRyvDLUuwGgxdemzkeY JZjQ== X-Gm-Message-State: AHQUAubFej3Il/Dy4JYoIT/3UEYUyDjyQkXRQZVM0oQJGbwTp3JBhhdg 3Z9vx09hGlKAvoQ16dNNcGjpgXhQ X-Google-Smtp-Source: AHgI3IazdhTOePC1Zv6uLRffTn21x5EQG3RNqI5ZUyn8xcB8Z4/KyLrLBtewWKsvmQ8jZm2hiIgALA== X-Received: by 2002:a63:e447:: with SMTP id i7mr5908204pgk.70.1550245071082; Fri, 15 Feb 2019 07:37:51 -0800 (PST) Received: from tomato.housegordon.com (moose.housegordon.com. [184.68.105.38]) by smtp.googlemail.com with ESMTPSA id e63sm13644502pfc.47.2019.02.15.07.37.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 15 Feb 2019 07:37:50 -0800 (PST) References: <87mumxf6xn.fsf@jidanni.org> From: Assaf Gordon Message-ID: Date: Fri, 15 Feb 2019 08:37:48 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.4.0 MIME-Version: 1.0 In-Reply-To: <87mumxf6xn.fsf@jidanni.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) severity 34488 wishlist retitle 34488 doc: sort: expand on "broken pipe" (SIGPIPE) behavior stop Hello, On 2019-02-15 7:43 a.m., 積丹尼 Dan Jacobson wrote: > Things start out cheery, but quickly get ugly, > > $ for i in 9 99 999 9999 99999; do seq $i|sort -n|sed 5q|wc -l; done > 5 > 5 > 5 > 5 > sort: write failed: 'standard output': Broken pipe > sort: write error > 5 > sort: write failed: 'standard output': Broken pipe > sort: write error > > Therefore, kindly add a sort --limit=n, I don't think this is wise, as "head -n5" does exactly that in much more generic way. > and/or on (info "(coreutils) sort invocation") > admit the problem, and give some workarounds, lest > our scripts occasionally spew error messages seemingly randomly, > just when the boss is looking. Just to clarify: why do you think this a "problem" ? This is the intended behavior of most proper programs: Upon receiving SIGPIPE they should terminal with an error, unless SIGPIPE is explicitly ignored. The errors are not "random" - they happen because you explicitly cut short the output of a program. It is an important indication about how your pipe works, and sort is not to blame, e.g.: $ seq 100000 | head -n1 1 seq: write error: Broken pipe $ seq 1000000| cat | head -n1 1 cat: write error: Broken pipe seq: write error: Broken pipe This is a good indication that the entire output was not consumed, and is very useful and important in some cases, e.g. when a program crashes before consuming all input. Here's a contrived example: $ seq 1000000 | sort -S 200 -T /foo/bar sort: cannot create temporary file in '/foo/bar': No such file or directory seq: write error: Broken pipe I force "sort" to fail (limiting it's memory usage and pointing it to non-existing temporarily directory). It is then good to know that seq's output was cut short and not consumed. If you know in advance you will trim the output of a program, either hide the stderr with "2>/dev/null", or use the shell's "trap PIPE" mechanism. > And no fair saying "just save the output" (could be big) "into a file > first, and do head(1) or sed(1) on that." If you want to consume all input and just print the first 5 lines, you can use "sed -n 1,5p" instead of "sed 5q" - no need for a temporary file. I'm marking this as a documentation "wishlist" item, and patches are always welcomed. regards, - assaf From unknown Sun Jun 15 01:09:57 2025 X-Loop: help-debbugs@gnu.org Subject: bug#34488: Add sort --limit, or document workarounds for sort|head error messages In-Reply-To: <87mumxf6xn.fsf@jidanni.org> Resent-From: =?UTF-8?Q?=E7=A9=8D=E4=B8=B9=E5=B0=BC?= Dan Jacobson Original-Sender: "Debbugs-submit" Resent-CC: bug-coreutils@gnu.org Resent-Date: Fri, 15 Feb 2019 15:50:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 34488 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: To: Assaf Gordon Cc: 34488@debbugs.gnu.org Received: via spool by 34488-submit@debbugs.gnu.org id=B34488.155024579114285 (code B ref 34488); Fri, 15 Feb 2019 15:50:01 +0000 Received: (at 34488) by debbugs.gnu.org; 15 Feb 2019 15:49:51 +0000 Received: from localhost ([127.0.0.1]:49695 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gufkN-0003iK-Cs for submit@debbugs.gnu.org; Fri, 15 Feb 2019 10:49:51 -0500 Received: from firebrick.maple.relay.mailchannels.net ([23.83.214.59]:59309) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gufkK-0003i7-9f for 34488@debbugs.gnu.org; Fri, 15 Feb 2019 10:49:49 -0500 X-Sender-Id: dreamhost|x-authsender|jidanni@jidanni.org Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id 2E0563E3A4D; Fri, 15 Feb 2019 15:49:46 +0000 (UTC) Received: from pdx1-sub0-mail-a80.g.dreamhost.com (unknown [100.96.19.74]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id D7F843E2404; Fri, 15 Feb 2019 15:49:45 +0000 (UTC) X-Sender-Id: dreamhost|x-authsender|jidanni@jidanni.org Received: from pdx1-sub0-mail-a80.g.dreamhost.com (pop.dreamhost.com [64.90.62.162]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384) by 0.0.0.0:2500 (trex/5.16.2); Fri, 15 Feb 2019 15:49:46 +0000 X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|jidanni@jidanni.org X-MailChannels-Auth-Id: dreamhost X-Illustrious-Ski: 4e6fe6aa6641e9ea_1550245785968_4047341934 X-MC-Loop-Signature: 1550245785967:1131510438 X-MC-Ingress-Time: 1550245785967 Received: from pdx1-sub0-mail-a80.g.dreamhost.com (localhost [127.0.0.1]) by pdx1-sub0-mail-a80.g.dreamhost.com (Postfix) with ESMTP id 67807807B9; Fri, 15 Feb 2019 07:49:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=jidanni.org; h=from:to:cc :subject:references:date:message-id:mime-version:content-type; s=jidanni.org; bh=BCNWcTuzSwXC3W9WCGW9OUBje+c=; b=dYv+A8hKzpooj kah8XqocPhVyLVpq41mpuJUZhK8s9376KsXi7mscYbuKK61E4O/O5/z/3TVXc1+S fC3JNUAgnzurvbjvYzPGZlve+Ee4bOMjhOfQlexyuVbHqyi8hUD/Lfn7rFsggfRc txiHmv7aeXYgs+kO47xkE0ahkRc3Iw= Received: from jidanni.org (114-41-34-44.dynamic-ip.hinet.net [114.41.34.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: jidanni@jidanni.org) by pdx1-sub0-mail-a80.g.dreamhost.com (Postfix) with ESMTPSA id 978E2807C6; Fri, 15 Feb 2019 07:49:44 -0800 (PST) X-DH-BACKEND: pdx1-sub0-mail-a80 From: =?UTF-8?Q?=E7=A9=8D=E4=B8=B9=E5=B0=BC?= Dan Jacobson References: <87mumxf6xn.fsf@jidanni.org> Date: Fri, 15 Feb 2019 23:49:38 +0800 Message-ID: <87ftspf3vx.fsf@jidanni.org> MIME-Version: 1.0 Content-Type: text/plain X-VR-OUT-STATUS: OK X-VR-OUT-SCORE: -100 X-VR-OUT-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedtledruddtjedgkedtucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuggftfghnshhusghstghrihgsvgdpffftgfetoffjqffuvfenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephffvufhffffkgggtsehttdertddttdejnecuhfhrohhmpejnnjjnucffrghnucflrggtohgsshhonhcuoehjihgurghnnhhisehjihgurghnnhhirdhorhhgqeenucfkphepuddugedrgedurdefgedrgeegnecurfgrrhgrmhepmhhouggvpehsmhhtphdphhgvlhhopehjihgurghnnhhirdhorhhgpdhinhgvthepuddugedrgedurdefgedrgeegpdhrvghtuhhrnhdqphgrthhhpeeprehuthhfqdekreeureehiehmpfehnfhiheehsgevkeerpecuffgrnhculfgrtghosghsohhnuceojhhiuggrnhhnihesjhhiuggrnhhnihdrohhrgheqpdhmrghilhhfrhhomhepjhhiuggrnhhnihesjhhiuggrnhhnihdrohhrghdpnhhrtghpthhtohepfeeggeekkeesuggvsggsuhhgshdrghhnuhdrohhrghenucevlhhushhtvghrufhiiigvpedt X-Spam-Score: 0.1 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.9 (/) >>>>> "AG" == Assaf Gordon writes: AG> The errors are not "random" - they happen because you explicitly AG> cut short the output of a program. Well the user thinks "hey I cut short 5 lines, 45 lines, 495 lines, and then one I got a job at a big company and cut short 4995 lines and got this error message just when the boss was looking." So be sure to mention it. Thanks. From unknown Sun Jun 15 01:09:57 2025 X-Loop: help-debbugs@gnu.org Subject: bug#34488: Add sort --limit, or document workarounds for sort|head error messages In-Reply-To: <87mumxf6xn.fsf@jidanni.org> Resent-From: =?UTF-8?Q?=E7=A9=8D=E4=B8=B9=E5=B0=BC?= Dan Jacobson Original-Sender: "Debbugs-submit" Resent-CC: bug-coreutils@gnu.org Resent-Date: Fri, 15 Feb 2019 16:54:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 34488 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: To: Eric Blake Cc: 34488@debbugs.gnu.org Received: via spool by 34488-submit@debbugs.gnu.org id=B34488.155024959820112 (code B ref 34488); Fri, 15 Feb 2019 16:54:02 +0000 Received: (at 34488) by debbugs.gnu.org; 15 Feb 2019 16:53:18 +0000 Received: from localhost ([127.0.0.1]:49743 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gugjm-0005EK-7T for submit@debbugs.gnu.org; Fri, 15 Feb 2019 11:53:18 -0500 Received: from palegreen.birch.relay.mailchannels.net ([23.83.209.140]:43704) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gugji-0005E8-Mw for 34488@debbugs.gnu.org; Fri, 15 Feb 2019 11:53:16 -0500 X-Sender-Id: dreamhost|x-authsender|jidanni@jidanni.org Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id 992765C4AE1; Fri, 15 Feb 2019 16:53:12 +0000 (UTC) Received: from pdx1-sub0-mail-a80.g.dreamhost.com (unknown [100.96.36.160]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id 3EFD65C5310; Fri, 15 Feb 2019 16:53:12 +0000 (UTC) X-Sender-Id: dreamhost|x-authsender|jidanni@jidanni.org Received: from pdx1-sub0-mail-a80.g.dreamhost.com (pop.dreamhost.com [64.90.62.162]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384) by 0.0.0.0:2500 (trex/5.16.2); Fri, 15 Feb 2019 16:53:12 +0000 X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|jidanni@jidanni.org X-MailChannels-Auth-Id: dreamhost X-Left-Language: 2e61655c0518f26e_1550249592416_2937650844 X-MC-Loop-Signature: 1550249592416:1740121007 X-MC-Ingress-Time: 1550249592415 Received: from pdx1-sub0-mail-a80.g.dreamhost.com (localhost [127.0.0.1]) by pdx1-sub0-mail-a80.g.dreamhost.com (Postfix) with ESMTP id E180E807DA; Fri, 15 Feb 2019 08:53:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=jidanni.org; h=from:to:cc :subject:references:date:message-id:mime-version:content-type; s=jidanni.org; bh=yT88Gt2GrcVntf1k4xMrXKJvR1A=; b=b3vmE32NdNPdX Z2f+l91W9bhRv1te+YHuFH80obGkJ2w4EWQFTC0P850yLktj9n3vBzn8oKFbFvuG X5W2wjvZW7Rzoza4KOHHb1ADTwI40q4kz1HF2DUywpWYZQ2UMYcw8ssXS4lulqGP d+zDfEZr92Q8Mtbf3cgPy53BKTzLJg= Received: from jidanni.org (114-41-34-44.dynamic-ip.hinet.net [114.41.34.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: jidanni@jidanni.org) by pdx1-sub0-mail-a80.g.dreamhost.com (Postfix) with ESMTPSA id 1224F807E2; Fri, 15 Feb 2019 08:53:10 -0800 (PST) X-DH-BACKEND: pdx1-sub0-mail-a80 From: =?UTF-8?Q?=E7=A9=8D=E4=B8=B9=E5=B0=BC?= Dan Jacobson References: <87mumxf6xn.fsf@jidanni.org> <49916778-4758-d040-5fcc-6e277a2dc183@redhat.com> Date: Sat, 16 Feb 2019 00:53:07 +0800 Message-ID: <875ztlf0y4.fsf@jidanni.org> MIME-Version: 1.0 Content-Type: text/plain X-VR-OUT-STATUS: OK X-VR-OUT-SCORE: -100 X-VR-OUT-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedtledruddtjedgleegucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuggftfghnshhusghstghrihgsvgdpffftgfetoffjqffuvfenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephffvufhffffkgggtsehttdertddttdejnecuhfhrohhmpejnnjjnucffrghnucflrggtohgsshhonhcuoehjihgurghnnhhisehjihgurghnnhhirdhorhhgqeenucfkphepuddugedrgedurdefgedrgeegnecurfgrrhgrmhepmhhouggvpehsmhhtphdphhgvlhhopehjihgurghnnhhirdhorhhgpdhinhgvthepuddugedrgedurdefgedrgeegpdhrvghtuhhrnhdqphgrthhhpeeprehuthhfqdekreeureehiehmpfehnfhiheehsgevkeerpecuffgrnhculfgrtghosghsohhnuceojhhiuggrnhhnihesjhhiuggrnhhnihdrohhrgheqpdhmrghilhhfrhhomhepjhhiuggrnhhnihesjhhiuggrnhhnihdrohhrghdpnhhrtghpthhtohepfeeggeekkeesuggvsggsuhhgshdrghhnuhdrohhrghenucevlhhushhtvghrufhiiigvpedt X-Spam-Score: 0.1 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.9 (/) >>>>> "EB" == Eric Blake writes: >> And no fair saying "just save the output" (could be big) "into a file >> first, and do head(1) or sed(1) on that." EB> If you have an app that exits noisily on write failures to an early-exit EB> pipe, your solutions are to quit ignoring SIGPIPE, or to change the EB> pipeline to consume all of the output instead of exiting early and EB> causing write failure. OK, it seems that indeed it would then be best to document: If you want to make sure no such errors occur on large output, instead of $ sort | head use $ sort > file; head file as an _easy to remember_ alternative amongst the many. And OK put this in some general place, and have the sort, etc. pages link to it. Thanks. From unknown Sun Jun 15 01:09:57 2025 X-Loop: help-debbugs@gnu.org Subject: bug#34488: Add sort --limit, or document workarounds for sort|head error messages Resent-From: Assaf Gordon Original-Sender: "Debbugs-submit" Resent-CC: bug-coreutils@gnu.org Resent-Date: Fri, 15 Feb 2019 21:41:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 34488 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: To: Eric Blake , =?UTF-8?Q?=E7=A9=8D=E4=B8=B9=E5=B0=BC?= Dan Jacobson , 34488@debbugs.gnu.org Received: via spool by 34488-submit@debbugs.gnu.org id=B34488.155026682921485 (code B ref 34488); Fri, 15 Feb 2019 21:41:02 +0000 Received: (at 34488) by debbugs.gnu.org; 15 Feb 2019 21:40:29 +0000 Received: from localhost ([127.0.0.1]:49849 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gulDX-0005aK-Um for submit@debbugs.gnu.org; Fri, 15 Feb 2019 16:40:28 -0500 Received: from mail-pf1-f179.google.com ([209.85.210.179]:41607) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gulDV-0005a5-MU for 34488@debbugs.gnu.org; Fri, 15 Feb 2019 16:40:18 -0500 Received: by mail-pf1-f179.google.com with SMTP id b7so5421264pfi.8 for <34488@debbugs.gnu.org>; Fri, 15 Feb 2019 13:40:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language; bh=WgVVjvCu8NApPIjvZgDuM0GfdsC3YuOwTiZpmqVBlCQ=; b=iSarsBmPqHHJZ3H3CoJD3FTyMakS/1EYCshOorHgD+Dir9pNpYKCLKOCUrDWYpL5Wo Jj9fP4MMO1uY33PQ2FhLF5NBcK44++P4CAWecIzpJv18HV14tmnbGJom6eCCnWc0Ylu+ G1NBoiqdbrfYrAqE3MYh1HhiKOl/SnxJ6tVKUxzQtckyRO7AOxOr0DBs3VVCmLReJ3VL WVdWS31qoPD2bGF5FuFvUZLehvJfPip1kJZG3NDr8Ry6o7sC0SFSEAGrw9K7LXkXf8Np Mrgjv4kvEbU2gHCQyQtERyTAeI2T3KhDGDxfL7osAKpsn+ATWwMqYU3y5fZJvCUpD/qY vi2g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language; bh=WgVVjvCu8NApPIjvZgDuM0GfdsC3YuOwTiZpmqVBlCQ=; b=SvHiQcMJKSpexrnDV2glx35DwL9nJLHZaEOXxNVYjrp7txIoWYRll3miKPb7r+ZvZj wH/xR44jupbD48hs0MAvEk7DPE9cXrJkHhvaTL93KugLakrFnghUs/RfBjhVMDwkg3gI BRllchCP9dJ6iesvo+J8Tkddifp8numRyYSJndpQOkYHifde6Pp2HsZ35sH8cltRmUwI +0XgnuDdXUag4fVZn+xutjT1xILUq8q6foN7YpnT2rHRtGa9IE6kpnxTS+YmGxMy4JRv dxRSaeiP8mraGD4zexnzmE4QjpwMSMsEjb/Tdt+rS3fopHGtTq8uFwCZNc2VKxZ7bQhw QmNg== X-Gm-Message-State: AHQUAuZsbWii8p7Y254V3HfJahXtf9dWTh2CHZlB985gS+A6PK8tJGIJ p42J6M1ge7Hm+22Ec4+rDDeqj3MM X-Google-Smtp-Source: AHgI3Ibh0q7RKau+fk5DFGbCnn3Qra/mIz72AGBYng0Dt+b6C6DvNiiq0kcs9EVmi74XLYrdUQthkg== X-Received: by 2002:a63:2c0e:: with SMTP id s14mr7392625pgs.132.1550266811105; Fri, 15 Feb 2019 13:40:11 -0800 (PST) Received: from tomato.housegordon.com (moose.housegordon.com. [184.68.105.38]) by smtp.googlemail.com with ESMTPSA id w4sm6422939pgk.16.2019.02.15.13.40.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 15 Feb 2019 13:40:08 -0800 (PST) References: <87mumxf6xn.fsf@jidanni.org> <49916778-4758-d040-5fcc-6e277a2dc183@redhat.com> From: Assaf Gordon Message-ID: <5b729a22-c3fa-b2b8-f204-ef27ed3a7292@gmail.com> Date: Fri, 15 Feb 2019 14:40:07 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.4.0 MIME-Version: 1.0 In-Reply-To: <49916778-4758-d040-5fcc-6e277a2dc183@redhat.com> Content-Type: multipart/mixed; boundary="------------23C2F83CCCD8BF7E4E95ACF7" Content-Language: en-US X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) This is a multi-part message in MIME format. --------------23C2F83CCCD8BF7E4E95ACF7 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Helo, On 2019-02-15 8:20 a.m., Eric Blake wrote: > On 2/15/19 8:43 AM, 積丹尼 Dan Jacobson wrote: >> sort: write failed: 'standard output': Broken pipe >> sort: write error [...] > Perhaps coreutils should teach 'env' a command-line option to forcefully > reset SIGPIPE back to default behavior [...] If we > did that, then even if your sh is started with SIGPIPE ignored (so that > the shell itself can't restore default behavior), you could do this > theoretical invocation: > > $ seq 9999 | env --default-signal PIPE sort -n | sed 5q | wc -l > 5 That is a nice idea, I could've used it myself couple of times. Attached a suggested patch. If this seems like a good direction, I'll complete it with NEWS/docs/etc. Usage is: env --default-signal=PIPE env -P ##shortcut to reset SIGPIPE env --default-signal=PIPE,INT,FOO This also works nicely with the recent 'env -S' option, so a script like so can always start with default SIGPIPE handler: #!/usr/bin/env -S -P sh seq inf | head -n1 comments welcomed, - assaf --------------23C2F83CCCD8BF7E4E95ACF7 Content-Type: text/x-patch; name="0001-env-new-option-D-default-signal-SIG-FIXME.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="0001-env-new-option-D-default-signal-SIG-FIXME.patch" >From d65ddf38cd5cf60ba6fc4f1bf60f7324a3e6bebd Mon Sep 17 00:00:00 2001 From: Assaf Gordon Date: Fri, 15 Feb 2019 12:31:48 -0700 Subject: [PATCH] env: new option -D/--default-signal=SIG [FIXME] See https://bugs.gnu.org/34488#8 . --- src/env.c | 90 +++++++++++++++++++++++++++++++++++++++- src/local.mk | 1 + tests/local.mk | 1 + tests/misc/env-signal-handler.sh | 68 ++++++++++++++++++++++++++++++ 4 files changed, 159 insertions(+), 1 deletion(-) create mode 100755 tests/misc/env-signal-handler.sh diff --git a/src/env.c b/src/env.c index 3a1a3869e..ebda91589 100644 --- a/src/env.c +++ b/src/env.c @@ -21,12 +21,16 @@ #include #include #include +#include +#include #include #include "system.h" #include "die.h" #include "error.h" +#include "operand2sig.h" #include "quote.h" +#include "sig2str.h" /* The official name of this program (e.g., no 'g' prefix). */ #define PROGRAM_NAME "env" @@ -48,7 +52,15 @@ static bool dev_debug; static char *varname; static size_t vnlen; -static char const shortopts[] = "+C:iS:u:v0 \t"; +/* if true, at least one signal handler should be reset. */ +static bool reset_signals ; + +/* if element [SIGNUM] is true, the signal handler's should be reset + to its defaut. */ +static bool signal_handlers[SIGNUM_BOUND]; + + +static char const shortopts[] = "+C:iPS:u:v0 \t"; static struct option const longopts[] = { @@ -56,6 +68,7 @@ static struct option const longopts[] = {"null", no_argument, NULL, '0'}, {"unset", required_argument, NULL, 'u'}, {"chdir", required_argument, NULL, 'C'}, + {"default-signal", optional_argument, NULL, 'P'}, {"debug", no_argument, NULL, 'v'}, {"split-string", required_argument, NULL, 'S'}, {GETOPT_HELP_OPTION_DECL}, @@ -88,8 +101,17 @@ Set each NAME to VALUE in the environment and run COMMAND.\n\ -C, --chdir=DIR change working directory to DIR\n\ "), stdout); fputs (_("\ + --default-signal=SIG reset signal SIG to its default signal handler.\n\ + multiple signals can be comma-separated.\n\ +"), stdout); + fputs (_("\ -S, --split-string=S process and split S into separate arguments;\n\ used to pass multiple arguments on shebang lines\n\ +"), stdout); + fputs (_("\ + -P same as --default-signal=PIPE\n\ +"), stdout); + fputs (_("\ -v, --debug print verbose information for each processing step\n\ "), stdout); fputs (HELP_OPTION_DESCRIPTION, stdout); @@ -525,6 +547,63 @@ parse_split_string (const char* str, int /*out*/ *orig_optind, *orig_optind = 0; /* tell getopt to restart from first argument */ } +static void +parse_signal_params (const char* optarg) +{ + char signame[SIG2STR_MAX]; + char *opt_sig; + char *optarg_writable = xstrdup (optarg); + + opt_sig = strtok (optarg_writable, ","); + while (opt_sig) + { + int signum = operand2sig (opt_sig, signame); + if (signum < 0) + usage (EXIT_FAILURE); + + signal_handlers[signum] = true; + + opt_sig = strtok (NULL, ","); + } + + free (optarg_writable); +} + +static void +reset_signal_handlers (void) +{ + + if (!reset_signals) + return; + + if (dev_debug) + devmsg ("Resetting signal handlers:\n"); + + for (int i=0; i. + +. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src +print_ver_ seq +trap_sigpipe_or_skip_ + +# Paraphrasing http://bugs.gnu.org/34488#8: +# POSIX requires that sh started with an inherited ignored SIGPIPE must +# silently ignore all attempts from within the shell to restore SIGPIPE +# handling to child processes of the shell: +# +# $ (trap '' PIPE; bash -c 'trap - PIPE; seq inf | head -n1') +# 1 +# seq: write error: Broken pipe +# +# With 'env --default-signal=PIPE', the signal handler can be reset to its +# default. + +# Baseline Test +# ------------- +# Ensure this results in a "broken pipe" error (the first 'trap' +# sets SIGPIPE to ignore, and the second 'trap' becomes a no-op instead +# of resetting SIGPIPE to its default). Upon a SIGPIPE 'seq' will not be +# terminated, instead its write(2) call will return an error. +(trap '' PIPE; sh -c 'trap - PIPE; seq 999999 2>err1t | head -n1 > out1') + +# The exact broken pipe message depends on the operating system, just ensure +# there was a 'write error' message in stderr: +sed 's/^\(seq: write error:\) .*/\1/' err1t > err1 || framework_failure_ + +printf "1\n" > exp-out || framework_failure_ +printf "seq: write error:\n" > exp-err1 || framework_failure_ + +compare exp-out out1 || framework_failure_ +compare exp-err1 err1 || framework_failure_ + + +# env test +# -------- +# With env resetting the signal handler to its defaults, there should be no +# error message (because the default SIGPIPE action is to terminate the +# 'seq' program): +(trap '' PIPE; + env --default-signal=PIPE \ + sh -c 'trap - PIPE; seq 999999 2>err2 | head -n1 > out2') + +compare exp-out out2 || fail=1 +compare /dev/null err2 || fail=1 + + + +Exit $fail -- 2.11.0 --------------23C2F83CCCD8BF7E4E95ACF7-- From unknown Sun Jun 15 01:09:57 2025 X-Loop: help-debbugs@gnu.org Subject: bug#34488: Add sort --limit, or document workarounds for sort|head error messages Resent-From: Eric Blake Original-Sender: "Debbugs-submit" Resent-CC: bug-coreutils@gnu.org Resent-Date: Fri, 15 Feb 2019 22:12:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 34488 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: To: Assaf Gordon , =?UTF-8?Q?=E7=A9=8D=E4=B8=B9=E5=B0=BC?= Dan Jacobson , 34488@debbugs.gnu.org Received: via spool by 34488-submit@debbugs.gnu.org id=B34488.155026868924180 (code B ref 34488); Fri, 15 Feb 2019 22:12:01 +0000 Received: (at 34488) by debbugs.gnu.org; 15 Feb 2019 22:11:29 +0000 Received: from localhost ([127.0.0.1]:49859 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gulhd-0006Ht-9S for submit@debbugs.gnu.org; Fri, 15 Feb 2019 17:11:26 -0500 Received: from mx1.redhat.com ([209.132.183.28]:35918) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gulhV-0006Ha-PS for 34488@debbugs.gnu.org; Fri, 15 Feb 2019 17:11:21 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 45DF8A0CB8; Fri, 15 Feb 2019 22:11:12 +0000 (UTC) Received: from [10.3.116.127] (ovpn-116-127.phx2.redhat.com [10.3.116.127]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 659FF5D6A9; Fri, 15 Feb 2019 22:11:11 +0000 (UTC) References: <87mumxf6xn.fsf@jidanni.org> <49916778-4758-d040-5fcc-6e277a2dc183@redhat.com> <5b729a22-c3fa-b2b8-f204-ef27ed3a7292@gmail.com> From: Eric Blake Openpgp: preference=signencrypt Autocrypt: addr=eblake@redhat.com; keydata= xsBNBEvHyWwBCACw7DwsQIh0kAbUXyqhfiKAKOTVu6OiMGffw2w90Ggrp4bdVKmCaEXlrVLU xphBM8mb+wsFkU+pq9YR621WXo9REYVIl0FxKeQo9dyQBZ/XvmUMka4NOmHtFg74nvkpJFCD TUNzmqfcjdKhfFV0d7P/ixKQeZr2WP1xMcjmAQY5YvQ2lUoHP43m8TtpB1LkjyYBCodd+LkV GmCx2Bop1LSblbvbrOm2bKpZdBPjncRNob73eTpIXEutvEaHH72LzpzksfcKM+M18cyRH+nP sAd98xIbVjm3Jm4k4d5oQyE2HwOur+trk2EcxTgdp17QapuWPwMfhaNq3runaX7x34zhABEB AAHNHkVyaWMgQmxha2UgPGVibGFrZUByZWRoYXQuY29tPsLAegQTAQgAJAIbAwULCQgHAwUV CgkICwUWAgMBAAIeAQIXgAUCS8fL9QIZAQAKCRCnoWtKJSdDahBHCACbl/5FGkUqJ89GAjeX RjpAeJtdKhujir0iS4CMSIng7fCiGZ0fNJCpL5RpViSo03Q7l37ss+No+dJI8KtAp6ID+PMz wTJe5Egtv/KGUKSDvOLYJ9WIIbftEObekP+GBpWP2+KbpADsc7EsNd70sYxExD3liwVJYqLc Rw7so1PEIFp+Ni9A1DrBR5NaJBnno2PHzHPTS9nmZVYm/4I32qkLXOcdX0XElO8VPDoVobG6 gELf4v/vIImdmxLh/w5WctUpBhWWIfQDvSOW2VZDOihm7pzhQodr3QP/GDLfpK6wI7exeu3P pfPtqwa06s1pae3ad13mZGzkBdNKs1HEm8x6zsBNBEvHyWwBCADGkMFzFjmmyqAEn5D+Mt4P zPdO8NatsDw8Qit3Rmzu+kUygxyYbz52ZO40WUu7EgQ5kDTOeRPnTOd7awWDQcl1gGBXgrkR pAlQ0l0ReO57Q0eglFydLMi5bkwYhfY+TwDPMh3aOP5qBXkm4qIYSsxb8A+i00P72AqFb9Q7 3weG/flxSPApLYQE5qWGSXjOkXJv42NGS6o6gd4RmD6Ap5e8ACo1lSMPfTpGzXlt4aRkBfvb NCfNsQikLZzFYDLbQgKBA33BDeV6vNJ9Cj0SgEGOkYyed4I6AbU0kIy1hHAm1r6+sAnEdIKj cHi3xWH/UPrZW5flM8Kqo14OTDkI9EtlABEBAAHCwF8EGAEIAAkFAkvHyWwCGwwACgkQp6Fr SiUnQ2q03wgAmRFGDeXzc58NX0NrDijUu0zx3Lns/qZ9VrkSWbNZBFjpWKaeL1fdVeE4TDGm I5mRRIsStjQzc2R9b+2VBUhlAqY1nAiBDv0Qnt+9cLiuEICeUwlyl42YdwpmY0ELcy5+u6wz mK/jxrYOpzXKDwLq5k4X+hmGuSNWWAN3gHiJqmJZPkhFPUIozZUCeEc76pS/IUN72NfprZmF Dp6/QDjDFtfS39bHSWXKVZUbqaMPqlj/z6Ugk027/3GUjHHr8WkeL1ezWepYDY7WSoXwfoAL 2UXYsMAr/uUncSKlfjvArhsej0S4zbqim2ZY6S8aRWw94J3bSvJR+Nwbs34GPTD4Pg== Organization: Red Hat, Inc. Message-ID: <4d4f04f0-8fae-5dd9-8f96-ad693b3f5388@redhat.com> Date: Fri, 15 Feb 2019 16:11:10 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.4.0 MIME-Version: 1.0 In-Reply-To: <5b729a22-c3fa-b2b8-f204-ef27ed3a7292@gmail.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="XFtnRdSeaZZttjOhnsOqmLEp9EVTbtUFK" X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Fri, 15 Feb 2019 22:11:12 +0000 (UTC) X-Spam-Score: -5.0 (-----) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -6.0 (------) This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --XFtnRdSeaZZttjOhnsOqmLEp9EVTbtUFK Content-Type: multipart/mixed; boundary="nCTOkjUslthAnE8DCUwZb2LBYU8p3vtfD"; protected-headers="v1" From: Eric Blake To: Assaf Gordon , =?UTF-8?B?56mN5Li55bC8IERhbiBKYWNvYnNvbg==?= , 34488@debbugs.gnu.org Message-ID: <4d4f04f0-8fae-5dd9-8f96-ad693b3f5388@redhat.com> Subject: Re: bug#34488: Add sort --limit, or document workarounds for sort|head error messages References: <87mumxf6xn.fsf@jidanni.org> <49916778-4758-d040-5fcc-6e277a2dc183@redhat.com> <5b729a22-c3fa-b2b8-f204-ef27ed3a7292@gmail.com> In-Reply-To: <5b729a22-c3fa-b2b8-f204-ef27ed3a7292@gmail.com> --nCTOkjUslthAnE8DCUwZb2LBYU8p3vtfD Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: quoted-printable On 2/15/19 3:40 PM, Assaf Gordon wrote: > Helo, >=20 > On 2019-02-15 8:20 a.m., Eric Blake wrote: >> On 2/15/19 8:43 AM, =E7=A9=8D=E4=B8=B9=E5=B0=BC Dan Jacobson wrote: >>> sort: write failed: 'standard output': Broken pipe >>> sort: write error > [...] >> Perhaps coreutils should teach 'env' a command-line option to forceful= ly >> reset SIGPIPE back to default behavior [...]=C2=A0=C2=A0 If we >> did that, then even if your sh is started with SIGPIPE ignored (so tha= t >> the shell itself can't restore default behavior), you could do this >> theoretical invocation: >> >> $ seq 9999 | env --default-signal PIPE sort -n | sed 5q | wc -l >> 5 >=20 > That is a nice idea, I could've used it myself couple of times. >=20 > Attached a suggested patch. > If this seems like a good direction, I'll complete it with NEWS/docs/et= c. Would we also want an easy way to ignore signals? That's a bit less of an issue, since you can use 'trap "" $SIG' in the shell; but having the symmetry in env may be nice (especially since using 'trap' is asymmetric in that you can't force the shell to un-ignore an inherited ignored signa= l). >=20 > Usage is: > =C2=A0=C2=A0=C2=A0 env --default-signal=3DPIPE > =C2=A0=C2=A0=C2=A0 env -P=C2=A0=C2=A0=C2=A0=C2=A0 ##shortcut to reset S= IGPIPE Nice, since that's probably the most common use case for it. > =C2=A0=C2=A0=C2=A0 env --default-signal=3DPIPE,INT,FOO >=20 >=20 > This also works nicely with the recent 'env -S' option, > so a script like so can always start with default SIGPIPE handler: >=20 > =C2=A0=C2=A0=C2=A0 #!/usr/bin/env -S -P sh > =C2=A0=C2=A0=C2=A0 seq inf | head -n1 Also nice. > =20 > -static char const shortopts[] =3D "+C:iS:u:v0 \t"; > +/* if true, at least one signal handler should be reset. */ > +static bool reset_signals ; Extra space. > + > +/* if element [SIGNUM] is true, the signal handler's should be reset > + to its defaut. */ default > +static bool signal_handlers[SIGNUM_BOUND]; > + > + > +static char const shortopts[] =3D "+C:iPS:u:v0 \t"; In the patch subject, you mentioned -D as a synonym to --default-signal, but it's missing here. (-P as a synonym to --default-signal=3DPIPE is fine, though) > =20 > static struct option const longopts[] =3D > { > @@ -56,6 +68,7 @@ static struct option const longopts[] =3D > {"null", no_argument, NULL, '0'}, > {"unset", required_argument, NULL, 'u'}, > {"chdir", required_argument, NULL, 'C'}, > + {"default-signal", optional_argument, NULL, 'P'}, Wait, you're making -P a synonym to --default-signal, even though -P takes no options but --default-signal does? And the fact that it is optional_argument means that you can't have a short option -D (that is, '--default-signal FOO' is NOT the same as '--default-signal=3DFOO', but treats FOO as a program name rather than a signal list). optional arguments can be odd; I'd consider using required_argument. > +static void > +parse_signal_params (const char* optarg) > +{ > + char signame[SIG2STR_MAX]; > + char *opt_sig; > + char *optarg_writable =3D xstrdup (optarg); > + > + opt_sig =3D strtok (optarg_writable, ","); > + while (opt_sig) > + { > + int signum =3D operand2sig (opt_sig, signame); > + if (signum < 0) > + usage (EXIT_FAILURE); Is blind usage() the best, or should we quote the unrecognized signal name via error() to call attention to which part of the command line fail= ed? > + > + signal_handlers[signum] =3D true; > + > + opt_sig =3D strtok (NULL, ","); > + } > + > + free (optarg_writable); > +} > + > +static void > +reset_signal_handlers (void) > +{ > + > + if (!reset_signals) > + return; > + > + if (dev_debug) > + devmsg ("Resetting signal handlers:\n"); > + > + for (int i=3D0; i + { > + struct sigaction act; > + > + if (!signal_handlers[i]) > + continue; > + > + if (dev_debug) > + { > + char signame[SIG2STR_MAX]; > + sig2str (i, signame); > + devmsg (" %s (%d)\n", signame, i); > + } > + > + if (sigaction (i, NULL, &act)) > + die (EXIT_CANCELED, errno, _("sigaction1(sig=3D%d) failed"),= i); > + > + act.sa_handler =3D SIG_DFL; > + if (sigaction (i, &act, NULL)) > + die (EXIT_CANCELED, errno, _("sigaction2(sig=3D%d) failed"),= i); Why do you have to call sigaction() twice? Is it to make sure the rest of &act is set up correctly? But what else in &act needs setup if you are going to set things to SIG_DFL? > + > + > + } > +} Why 2 blank lines? > + > int > main (int argc, char **argv) > { > @@ -558,6 +637,13 @@ main (int argc, char **argv) > case '0': > opt_nul_terminate_output =3D true; > break; > + case 'P': > + reset_signals =3D true; > + if (optarg) > + parse_signal_params (optarg); > + else > + signal_handlers[SIGPIPE] =3D true; > + break; Hmm - you made it optional so that '--default-signal' and '--default-signal=3DPIPE' can be synonyms. If so, the help text in usage() should definitely call out "--default-signal[=3DLIST]" to make it= obvious that LIST is an optional argument. > +++ b/tests/misc/env-signal-handler.sh > +. "${srcdir=3D.}/tests/init.sh"; path_prepend_ ./src > +print_ver_ seq > +trap_sigpipe_or_skip_ Hmm - I wonder if trap_sigpipe_or_skip_ could be updated to take advantage of our just-built env :) > + > +# Paraphrasing http://bugs.gnu.org/34488#8: > +# POSIX requires that sh started with an inherited ignored SIGPIPE mus= t > +# silently ignore all attempts from within the shell to restore SIGPIP= E > +# handling to child processes of the shell: > +# > +# $ (trap '' PIPE; bash -c 'trap - PIPE; seq inf | head -n1') > +# 1 > +# seq: write error: Broken pipe > +# > +# With 'env --default-signal=3DPIPE', the signal handler can be reset = to its > +# default. > + > +# Baseline Test > +# ------------- > +# Ensure this results in a "broken pipe" error (the first 'trap' > +# sets SIGPIPE to ignore, and the second 'trap' becomes a no-op instea= d > +# of resetting SIGPIPE to its default). Upon a SIGPIPE 'seq' will not = be > +# terminated, instead its write(2) call will return an error. > +(trap '' PIPE; sh -c 'trap - PIPE; seq 999999 2>err1t | head -n1 > out= 1') > + > +# The exact broken pipe message depends on the operating system, just = ensure > +# there was a 'write error' message in stderr: > +sed 's/^\(seq: write error:\) .*/\1/' err1t > err1 || framework_failur= e_ > + > +printf "1\n" > exp-out || framework_failure_ > +printf "seq: write error:\n" > exp-err1 || framework_failure_ > + > +compare exp-out out1 || framework_failure_ > +compare exp-err1 err1 || framework_failure_ Nice setup. > + > + > +# env test > +# -------- > +# With env resetting the signal handler to its defaults, there should = be no > +# error message (because the default SIGPIPE action is to terminate th= e > +# 'seq' program): > +(trap '' PIPE; > + env --default-signal=3DPIPE \ > + sh -c 'trap - PIPE; seq 999999 2>err2 | head -n1 > out2') Perhaps you could also test: (trap '' PIPE; env --default-signal=3DPIPE seq 999999 2>err3 | head -n1 >= out3) But in general I like the patch. --=20 Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3226 Virtualization: qemu.org | libvirt.org --nCTOkjUslthAnE8DCUwZb2LBYU8p3vtfD-- --XFtnRdSeaZZttjOhnsOqmLEp9EVTbtUFK Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAEBCAAdFiEEccLMIrHEYCkn0vOqp6FrSiUnQ2oFAlxnOP4ACgkQp6FrSiUn Q2rlaAgAhvFFBGldbWZgVnnWqxYiBTYq2/gaIT9GR2oR43P1IyJPgpht1qT3y4tc tLKNQKVop9PT6GqTFemtnMuO5LNh9axRWl7bfyOqB8bo2SBlehZtBBBxOLAYxcNd qzaQ4Pv0vw8j3Cm93XYTSyRxe0qu4V6S9tMVd2duNFe1glpR3waSY+ngYa7LKev+ mWfsPV2k+WS4+nuLvw2Ow68Gq9x4Lvg6qbI0whU+jK0yJoSS7/b99Y1KTJ0fEfgW MaoWu8ckGHd0sNEeHv6DTportN6XKOs16OWCDfq6UyTERPYAZd6zlDBqyT8Jxi6J qZ1rDMRoaKE36yc6tmc8FJ6h6v8irg== =2T8U -----END PGP SIGNATURE----- --XFtnRdSeaZZttjOhnsOqmLEp9EVTbtUFK-- From unknown Sun Jun 15 01:09:57 2025 X-Loop: help-debbugs@gnu.org Subject: bug#34488: Add sort --limit, or document workarounds for sort|head error messages Resent-From: Paul Eggert Original-Sender: "Debbugs-submit" Resent-CC: bug-coreutils@gnu.org Resent-Date: Fri, 15 Feb 2019 22:43:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 34488 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: To: =?UTF-8?Q?=E7=A9=8D=E4=B8=B9=E5=B0=BC?= Dan Jacobson , Assaf Gordon Cc: 34488@debbugs.gnu.org Received: via spool by 34488-submit@debbugs.gnu.org id=B34488.155027054827035 (code B ref 34488); Fri, 15 Feb 2019 22:43:02 +0000 Received: (at 34488) by debbugs.gnu.org; 15 Feb 2019 22:42:28 +0000 Received: from localhost ([127.0.0.1]:49893 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gumBf-00071z-JU for submit@debbugs.gnu.org; Fri, 15 Feb 2019 17:42:27 -0500 Received: from zimbra.cs.ucla.edu ([131.179.128.68]:45340) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gumBc-00071l-Jq for 34488@debbugs.gnu.org; Fri, 15 Feb 2019 17:42:27 -0500 Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 95E1A161306; Fri, 15 Feb 2019 14:42:18 -0800 (PST) Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id neStMV31tmpJ; Fri, 15 Feb 2019 14:42:17 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id D796016131D; Fri, 15 Feb 2019 14:42:17 -0800 (PST) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id mrv38BR4rcrX; Fri, 15 Feb 2019 14:42:17 -0800 (PST) Received: from Penguin.CS.UCLA.EDU (Penguin.CS.UCLA.EDU [131.179.64.200]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id BD4691612F3; Fri, 15 Feb 2019 14:42:17 -0800 (PST) References: <87mumxf6xn.fsf@jidanni.org> <87ftspf3vx.fsf@jidanni.org> From: Paul Eggert Openpgp: preference=signencrypt Autocrypt: addr=eggert@cs.ucla.edu; prefer-encrypt=mutual; keydata= xsFNBEyAcmQBEADAAyH2xoTu7ppG5D3a8FMZEon74dCvc4+q1XA2J2tBy2pwaTqfhpxxdGA9 Jj50UJ3PD4bSUEgN8tLZ0san47l5XTAFLi2456ciSl5m8sKaHlGdt9XmAAtmXqeZVIYX/UFS 96fDzf4xhEmm/y7LbYEPQdUdxu47xA5KhTYp5bltF3WYDz1Ygd7gx07Auwp7iw7eNvnoDTAl KAl8KYDZzbDNCQGEbpY3efZIvPdeI+FWQN4W+kghy+P6au6PrIIhYraeua7XDdb2LS1en3Ss mE3QjqfRqI/A2ue8JMwsvXe/WK38Ezs6x74iTaqI3AFH6ilAhDqpMnd/msSESNFt76DiO1ZK QMr9amVPknjfPmJISqdhgB1DlEdw34sROf6V8mZw0xfqT6PKE46LcFefzs0kbg4GORf8vjG2 Sf1tk5eU8MBiyN/bZ03bKNjNYMpODDQQwuP84kYLkX2wBxxMAhBxwbDVZudzxDZJ1C2VXujC OJVxq2kljBM9ETYuUGqd75AW2LXrLw6+MuIsHFAYAgRr7+KcwDgBAfwhPBYX34nSSiHlmLC+ KaHLeCLF5ZI2vKm3HEeCTtlOg7xZEONgwzL+fdKo+D6SoC8RRxJKs8a3sVfI4t6CnrQzvJbB n6gxdgCu5i29J1QCYrCYvql2UyFPAK+do99/1jOXT4m2836j1wARAQABzSBQYXVsIEVnZ2Vy dCA8ZWdnZXJ0QGNzLnVjbGEuZWR1PsLBfgQTAQIAKAUCTIByZAIbAwUJEswDAAYLCQgHAwIG FQgCCQoLBBYCAwECHgECF4AACgkQ7ZfpDmKqfjRRGw/+Ij03dhYfYl/gXVRiuzV1gGrbHk+t nfrI/C7fAeoFzQ5tVgVinShaPkZo0HTPf18x6IDEdAiO8Mqo1yp0CtHmzGMCJ50o4Grgfjlr 6g/+vtEOKbhleszN2XpJvpwM2QgGvn/laTLUu8PH9aRWTs7qJJZKKKAb4sxYc92FehPu6FOD 0dDiyhlDAq4lOV2mdBpzQbiojoZzQLMQwjpgCTK2572eK9EOEQySUThXrSIz6ASenp4NYTFH s9tuJQvXk9gZDdPSl3bp+47dGxlxEWLpBIM7zIONw4ks4azgT8nvDZxA5IZHtvqBlJLBObYY 0Le61Wp0y3TlBDh2qdK8eYL426W4scEMSuig5gb8OAtQiBW6k2sGUxxeiv8ovWu8YAZgKJfu oWI+uRnMEddruY8JsoM54KaKvZikkKs2bg1ndtLVzHpJ6qFZC7QVjeHUh6/BmgvdjWPZYFTt N+KA9CWX3GQKKgN3uu988yznD7LnB98T4EUH1HA/GnfBqMV1gpzTvPc4qVQinCmIkEFp83zl +G5fCjJJ3W7ivzCnYo4KhKLpFUm97okTKR2LW3xZzEW4cLSWO387MTK3CzDOx5qe6s4a91Zu ZM/j/TQdTLDaqNn83kA4Hq48UHXYxcIh+Nd8k/3w6lFuoK0wrOFiywjLx+0ur5jmmbecBGHc 1xdhAFHOwU0ETIByZAEQAKaF678T9wyH4wjTrV1Pz3cDEoSnV/0ZUrOT37p1dcGyj/IXq1x6 70HRVahAmk0sZpYc25PF9D5GPYHFWlNjuPU96rDndXB3hedmBRhLdC4bAXjI4DV+bmdVe+q/ IMnlZRaVlm9EiMCVAR6w13sReu7qXkW9r3RwY2AzXskp/tAe4BRKr1Zmbvi2nbnQ6epEC42r Rbx0B1EhjbIQZ5JHGk24iPT7LdBgnNmos5wYjzwNlkMQD5T0Ydzhk7J+UxwA5m46mOhRDC2r FV/A0gm5TLy8DXjv/Esc4gYnYai6SQqnUEVh5LuV8YCJBnijs+Tiw71x1icmn6xGI45EugJO gec+rLypYgpVp4x0HI5T88qBRYCkxH3Kg8Qo+EWNA9A4LRQ9DX8njona0gf0s03tocK8kBN6 6UoqqPtHBnc4eMgBymCflK12eKfd2YYxnyg9cZazWA5VslvTxpm76hbg5oiAEH/Vg/8MxHyA nPhfrgwyPrmJEcVBafdspJnYQxBYNco2LFPIhlOvWh8r4at+s+M3Lb26oUTczlgdW1Sf3SDA 77BMRnF0FQyE+7AzV79MBN4ykiqaezQxtaF1Fy/tvkhffSo8u+dwG0EgJh+te38gTcISVr0G IPplLz6YhjrbHrPRF1CN5UuL9DBGjxuN35RLNVEfta6RUFlR6NctTjvrABEBAAHCwWUEGAEC AA8FAkyAcmQCGwwFCRLMAwAACgkQ7ZfpDmKqfjSrHA/+KzAKvTxRhA9MWNLxIyJ7S5uJ16gs T3oCjZrBKGEhKMOGX4O0GA6VOEryO7QRCCYah3oxSG38IAnNeiwJXgU9Bzkk85UGbPEd7HGF /VSeHCQwWou6jqUDTSDvn9YhNTdG0KXPM74aC+xr2Zow1O2mhXihgWKD0Dw+0LYPnUOsQ0KO FxHXXYHmRrS1OZPU59BLvc+TRhIhafSHKLwbXK+6ckkxBx6h8z5ccpG0Qs4bFhdFYnFrEieD LoGmnE2YLhdV6swJ9VNCS6pLiEohT3fm7aXm15tZOIyzMZhHRSAPblXxQ0ZSWjq8oRrcYNFx c4W1URpAkBCOYJoXvQfD5L3lqAl8TCqDUzYxhH/tJhbDdHrqHH767jaDaTB1+Talp/2AMKwc XNOdiklGxbmHVG6YGl6g8Lrbsu9NZEI4yLlHzuikthJWgz+3vZhVGyNlt+HNIoF6CjDL2omu 5cEq4RDHM44QqPk6l7O0pUvN1mT4B+S1b08RKpqm/ff015E37HNV/piIvJlxGAYz8PSfuGCB 1thMYqlmgdhd9/BabGFbGGYHA6U4/T5zqU+f6xHy1SsAQZ1MSKlLwekBIT+4/cLRGqCHjnV0 q5H/T6a7t5mPkbzSrOLSo4puj+IToNjYyYIDBWzhlA19avOa+rvUjmHtD3sFN7cXWtkGoi8b uNcby4U= Organization: UCLA Computer Science Department Message-ID: Date: Fri, 15 Feb 2019 14:42:17 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.5.0 MIME-Version: 1.0 In-Reply-To: <87ftspf3vx.fsf@jidanni.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: quoted-printable X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) On 2/15/19 7:49 AM, =E7=A9=8D=E4=B8=B9=E5=B0=BC Dan Jacobson wrote: > Well the user thinks "hey I cut short 5 lines, 45 lines, 495 lines, and > then one I got a job at a big company and cut short 4995 lines and got > this error message just when the boss was looking." I'm afraid I'll have to disagree on this one. This is a generic problem=20 for any program that writes to standard output, and is not peculiar to=20 'sort'. The 'sort' documentation is not the right place to document this=20 issue, just as it's not the right place to document what happens when=20 you type control-C to interrupt a sort. From unknown Sun Jun 15 01:09:57 2025 X-Loop: help-debbugs@gnu.org Subject: bug#34488: Add sort --limit, or document workarounds for sort|head error messages Resent-From: Bernhard Voelker Original-Sender: "Debbugs-submit" Resent-CC: bug-coreutils@gnu.org Resent-Date: Sat, 16 Feb 2019 23:57:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 34488 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: To: Assaf Gordon , Eric Blake , =?UTF-8?Q?=E7=A9=8D=E4=B8=B9=E5=B0=BC?= Dan Jacobson , 34488@debbugs.gnu.org Received: via spool by 34488-submit@debbugs.gnu.org id=B34488.15503613915924 (code B ref 34488); Sat, 16 Feb 2019 23:57:02 +0000 Received: (at 34488) by debbugs.gnu.org; 16 Feb 2019 23:56:31 +0000 Received: from localhost ([127.0.0.1]:50622 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gv9os-0001XU-PH for submit@debbugs.gnu.org; Sat, 16 Feb 2019 18:56:30 -0500 Received: from mout.kundenserver.de ([217.72.192.75]:54827) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gv9or-0001XA-4O for 34488@debbugs.gnu.org; Sat, 16 Feb 2019 18:56:29 -0500 Received: from [192.168.101.10] ([93.218.109.128]) by mrelayeu.kundenserver.de (mreue108 [212.227.15.183]) with ESMTPSA (Nemesis) id 1N33AR-1h32d00ySr-013Qxp; Sun, 17 Feb 2019 00:56:15 +0100 References: <87mumxf6xn.fsf@jidanni.org> <49916778-4758-d040-5fcc-6e277a2dc183@redhat.com> <5b729a22-c3fa-b2b8-f204-ef27ed3a7292@gmail.com> From: Bernhard Voelker Openpgp: preference=signencrypt Autocrypt: addr=mail@bernhard-voelker.de; prefer-encrypt=mutual; keydata= mQENBFPirzMBCACyzYldTjQ4ufFOkByY5Nn5USb5GFoL48nWBwNHjd9KUbtRRNlQiPNKd6hK Gvd3BGi5aoFKA4ytfRk6jbAbW3jVb3R8wYaV08mOy4KVEKxqN4bxsXlMjNChXVR+rtKDmfI+ oPTL+cPH2X6gW4W02IRbVw0uUhNm6zEedC/gNrY/mTlf1enZ46jxZ7BTUZaG+kx38UMISIMB zSzLRtdkwgmHj4jS3p1fF2cwRqLclIfMjKGpbNFPEXeXKWrCLcqHw78795eAR9q0YvrDkfIn GdDBwfb3VM4NdulwIFzvYZMSXvSbbyPLB5YkHU5aAWQHUse4WlfT5ccDpbzUYldRAvF9ABEB AAG0K0Jlcm5oYXJkIFZvZWxrZXIgPG1haWxAYmVybmhhcmQtdm9lbGtlci5kZT6JATkEEwEC ACMFAlPirzMCGwMHCwkIBwMCAQYVCAIJCgsEFgIDAQIeAQIXgAAKCRBGUC73lpFxle5wCACC dbs0QaJ0vR3Sff2cKdTk41rUq3YfWngsR///IOU0C5DdkePmCnJE/lUsUy0LRTxcUDLxQR+x QHU8ssRT0JUO9726dI3miy36UdsgmBYaOtLvQcidGmW1R7o0PYYf04+TFtyqKgngOUBPpMgR 6o4UsQxy/OD4bN1WDqOgIjL+D/qJpkKmgp6L6+hhaBCpiOFKRmmV7YyQ3SqVlfQNiHs5ZtkR nXpIjgZARV+GllKucI17bO0CGmTJZ1tstVy0+W3DQT1lbBkTTc++5LONM99D3jjn23l1ocOp folR53F7I4cb2RNfT23v1I59RH37lB9wMOqrKj0UjYAC2YoPGQ3BuQENBFPirzMBCADXLWWp QihBldY6reca8ZKdc3T9qXEOa3akE3DWKztIBmNJhtYOjmpLYajQTkGa7UoJTnbmZE2Rn6ZE oNnvb0gcFNAIcY95KOI+bjOR8HEgh4cx2REXh6L6olIgyXqt/KFusE4wtVZAFxZl+30HzN6n D+1HvrjXxPJRX6MsIYOYyyX9/6OofwJK6QHODYGp8WL2olHDnmsXg4AT6Wlr7qKpKrQELlcF R4xkvdmgL/Ghw/tK0yJTxMIcewCCZWLPOXRmFRbvAadZWPAgVsJ63siNyUlVnVMSzDgTJl+s l/DMabXpqrJQx3/1Yy6mTaDs3XZT/wmBKaTLXx/LByaPxQQ7ABEBAAGJAR8EGAECAAkFAlPi rzMCGwwACgkQRlAu95aRcZWVPwgAqZT6iTXkoP37wYb41323RzhBcJ8JSk4cyBDBUXX0lMrM 3qhiClKG7phpxVdu817Gwc6Hsecg7FfjQAV8MHQ0ZFeEFdk3b2rKBqfsStc+h49/xF3Fb+if CzR9qeQF82fMSxkg18++7hMcHCMO/hPZ/Q0xRi+lrSr2QKDJQuLzSyVU14TxrCkevZjEhtma VNvcJlJzCbiBXee9Fpc5jITUXPFG8E8dxqo1n+duOyIMgozrAnzP7X5V/Ob/Ozf/aGGX9+Jd inyfCX18nWcHALKMU/36Eua/ylalf/2c2YkBp9KCLVmGgPkUgW52EeRPgroIsiwu+rwCSV6Z UyCJ+OymCg== Message-ID: Date: Sun, 17 Feb 2019 00:56:13 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.5.0 MIME-Version: 1.0 In-Reply-To: <5b729a22-c3fa-b2b8-f204-ef27ed3a7292@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Provags-ID: V03:K1:TPYmkBBqnlwYN2eLv1Dd+MpHrFeziRQxS3i/xAEaZAgErwkWQXG gbwZ/Xt+Yps1JGWHgKsUnlILoujDWL/8N/C/0gbch4wKtyxb49x976+ddjBNqS6LlUq0c4X NuhmTZesVU7GGY4ZLQP4OVeRBuyFFlrR5ycdmhKMSMufY0lJhk0259JN0Gj7b0dVp9DJU1B xVt3/+JwKiY+ApU+Iieig== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1;V03:K0:OkAmYigO1zQ=:EtsJPkASKmsuzfjCl2z64H lxYfoFx7pG9CIsMOOxTEZCGpzCRNZwHMysfhYCK5isE62umrcbjZQ6jDOOPSmjt7EQyun3SXA J8YL2IurjiVYAxRYKPSmcQ3NsLDjyKJA0ApbRg7G2ECoyJLK4uL5mSk9R3ZQCYQynjmVvnGu1 QSp6yq+SgnNNFJJUAIL1YBTNZdNPgp7O2e+kKNNGw5T8GLE3SpU0LHP/RCUB3f7dxlKPp/iMb 9Ze0yG2s5IeJUbDbinnRYY9Jro9mZYl6vLt9SuA77uDntrngvefHm1x3+e79H+k+RrQMnrK3k ImsrT0GjlVB4UJErNkOEilZ6ZAHi9nfkntaPFUaRYvbPc54pH6bvC2DQPQEyPgSPN4+UnKMWr kmuwbdwUCUpTAzt2yTX5DTZQf7BO3elI4EmWKv6IRCMGOtQmHcIg1TbGHSzI7mE1UAZWy89E3 oNwmFbZNQ/HOGZ/xWkk3MIaJ/6dMzGMLTNvb8kvmVL7/b6deGIrK5hmYWjewPwoAwPt9R95zx ch3v4eP64+QbhDoXhNCAHsUhcXRsp/YkszPrz+yzQhC6kX5eOXV26jQVK6va2lVqzqFgJZqLW npKJ0k8Juicgl6YCOaVTHwzmSwl4uCI3adMwZqhWW15mujU+KEEupVREwdbGjLzgMunJZAYwb 2+XWBHktIF2u8bKJZC94WxedvyhFX3r3tG8E6OWpJO8dlZeAZ+F7Z/2KKnU+zSZtsng5eJAXW oPCWhuY3fUVHo6qNP4m1R9SkzQe1ATYT3R83+oh1OnBNajmnMH/RV4UGfK3t5QVosZGQN4bD+ N7JZym6 X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) On 2/15/19 10:40 PM, Assaf Gordon wrote: >> $ seq 9999 | env --default-signal PIPE sort -n | sed 5q | wc -l >> 5 > > That is a nice idea, I could've used it myself couple of times. > > Attached a suggested patch. > If this seems like a good direction, I'll complete it with NEWS/docs/etc. > src/env.c | 90 +++++++++++++++++++++++++++++++++++++++- That's quite a lot of new code. What about a new program ... quick shot (and maybe an unlucky name): 'trap' ? Have a nice day, Berny From unknown Sun Jun 15 01:09:57 2025 X-Loop: help-debbugs@gnu.org Subject: bug#34488: Add sort --limit, or document workarounds for sort|head error messages In-Reply-To: <87mumxf6xn.fsf@jidanni.org> Resent-From: =?UTF-8?Q?=E7=A9=8D=E4=B8=B9=E5=B0=BC?= Dan Jacobson Original-Sender: "Debbugs-submit" Resent-CC: bug-coreutils@gnu.org Resent-Date: Sun, 17 Feb 2019 07:25:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 34488 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: To: Bernhard Voelker Cc: 34488@debbugs.gnu.org, Assaf Gordon , Eric Blake Received: via spool by 34488-submit@debbugs.gnu.org id=B34488.155038829016393 (code B ref 34488); Sun, 17 Feb 2019 07:25:01 +0000 Received: (at 34488) by debbugs.gnu.org; 17 Feb 2019 07:24:50 +0000 Received: from localhost ([127.0.0.1]:50680 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gvGok-0004GK-9T for submit@debbugs.gnu.org; Sun, 17 Feb 2019 02:24:50 -0500 Received: from bisque.maple.relay.mailchannels.net ([23.83.214.18]:36714) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gvGoh-0004GB-NA for 34488@debbugs.gnu.org; Sun, 17 Feb 2019 02:24:49 -0500 X-Sender-Id: dreamhost|x-authsender|jidanni@jidanni.org Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id E195D502664; Sun, 17 Feb 2019 07:24:45 +0000 (UTC) Received: from pdx1-sub0-mail-a71.g.dreamhost.com (unknown [100.96.30.62]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id 95E8C50268C; Sun, 17 Feb 2019 07:24:45 +0000 (UTC) X-Sender-Id: dreamhost|x-authsender|jidanni@jidanni.org Received: from pdx1-sub0-mail-a71.g.dreamhost.com (pop.dreamhost.com [64.90.62.162]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384) by 0.0.0.0:2500 (trex/5.16.2); Sun, 17 Feb 2019 07:24:45 +0000 X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|jidanni@jidanni.org X-MailChannels-Auth-Id: dreamhost X-Towering-Tangy: 0d8da629360bce11_1550388285777_582831002 X-MC-Loop-Signature: 1550388285777:1168166225 X-MC-Ingress-Time: 1550388285776 Received: from pdx1-sub0-mail-a71.g.dreamhost.com (localhost [127.0.0.1]) by pdx1-sub0-mail-a71.g.dreamhost.com (Postfix) with ESMTP id EDAB681E2B; Sat, 16 Feb 2019 23:24:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=jidanni.org; h=from:to:cc :subject:references:date:message-id:mime-version:content-type; s=jidanni.org; bh=7CjFUfgifFk50xaLrsuP8KgUs2k=; b=lqZz8tWmNWg1+ JR0TaTRUxZcVATskWD3j6Ke6Dlg1mcMzdG5c4Nj1YXhpfUsGQw92yYC7afGOoXTm 8E/EQf0x5YKSrpgRmuIwBvN16pbEkOFuypJvx65LooWdOhnoqXehVZLVeXP6NtII CbmeBVt9VH4lGsBtYqZSePR4W7jDco= Received: from jidanni.org (111-246-86-62.dynamic-ip.hinet.net [111.246.86.62]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: jidanni@jidanni.org) by pdx1-sub0-mail-a71.g.dreamhost.com (Postfix) with ESMTPSA id E7EB281E47; Sat, 16 Feb 2019 23:24:43 -0800 (PST) X-DH-BACKEND: pdx1-sub0-mail-a71 From: =?UTF-8?Q?=E7=A9=8D=E4=B8=B9=E5=B0=BC?= Dan Jacobson References: <87mumxf6xn.fsf@jidanni.org> <49916778-4758-d040-5fcc-6e277a2dc183@redhat.com> <5b729a22-c3fa-b2b8-f204-ef27ed3a7292@gmail.com> Date: Sun, 17 Feb 2019 15:24:38 +0800 Message-ID: <87wolyswqx.fsf@jidanni.org> MIME-Version: 1.0 Content-Type: text/plain X-VR-OUT-STATUS: OK X-VR-OUT-SCORE: -100 X-VR-OUT-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedtledruddutddguddthecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucggtfgfnhhsuhgsshgtrhhisggvpdfftffgtefojffquffvnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpefhvffufhffkfggtgesthdtredttddtjeenucfhrhhomhepnjjnnjcuffgrnhculfgrtghosghsohhnuceojhhiuggrnhhnihesjhhiuggrnhhnihdrohhrgheqnecukfhppeduuddurddvgeeirdekiedriedvnecurfgrrhgrmhepmhhouggvpehsmhhtphdphhgvlhhopehjihgurghnnhhirdhorhhgpdhinhgvthepudduuddrvdegiedrkeeirdeivddprhgvthhurhhnqdhprghthheppeeruhhtfhdqkeerueerheeimhfphefnihehhegsveekreepucffrghnucflrggtohgsshhonhcuoehjihgurghnnhhisehjihgurghnnhhirdhorhhgqedpmhgrihhlfhhrohhmpehjihgurghnnhhisehjihgurghnnhhirdhorhhgpdhnrhgtphhtthhopeefgeegkeekseguvggssghughhsrdhgnhhurdhorhhgnecuvehluhhsthgvrhfuihiivgeptd X-Spam-Score: 0.1 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.9 (/) (I recall I heard about 50 years ago when pipe buffers first came to Unix they were supposed to be invisible to the user...) From unknown Sun Jun 15 01:09:57 2025 X-Loop: help-debbugs@gnu.org Subject: bug#34488: Add sort --limit, or document workarounds for sort|head error messages Resent-From: Assaf Gordon Original-Sender: "Debbugs-submit" Resent-CC: bug-coreutils@gnu.org Resent-Date: Sun, 17 Feb 2019 16:29:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 34488 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: To: Bernhard Voelker , Eric Blake , =?UTF-8?Q?=E7=A9=8D=E4=B8=B9=E5=B0=BC?= Dan Jacobson , 34488@debbugs.gnu.org Received: via spool by 34488-submit@debbugs.gnu.org id=B34488.155042090426135 (code B ref 34488); Sun, 17 Feb 2019 16:29:02 +0000 Received: (at 34488) by debbugs.gnu.org; 17 Feb 2019 16:28:24 +0000 Received: from localhost ([127.0.0.1]:51496 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gvPIm-0006nT-GN for submit@debbugs.gnu.org; Sun, 17 Feb 2019 11:28:24 -0500 Received: from mail-pf1-f196.google.com ([209.85.210.196]:34844) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gvPIk-0006nF-UB for 34488@debbugs.gnu.org; Sun, 17 Feb 2019 11:28:23 -0500 Received: by mail-pf1-f196.google.com with SMTP id j5so2793367pfa.2 for <34488@debbugs.gnu.org>; Sun, 17 Feb 2019 08:28:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language:content-transfer-encoding; bh=u6xr/fuUAw4R+YhTkYLa6tbcWlMca39fHqKFBsQm5nI=; b=ZPxOuJctsLXIp+yXuHkR/soGhwZmWFgBrTdMORGfO6gK0yZprLesrIjw3/m1W5i1jo O+fNZyxzASFJ0UrKS0H+PDqMQvqg1oSX7noTgykTj+WGRMXZT8809QxlJjeHcea/Kywi Q30I8oJqInjkVFvfT2o+TlXpkDzwTmr4KBhyWSXsW2HieE83VseFbgEo83uy9dyROkN9 K0A7miyDCbfUVii31uBySOJzOui140Rvg7V0Hgi0wC/fUx5sPwh1ka166T0l1uzlxbxw IZ+0cZkGnrT9LcRPVUwL+sMdHVpXhGzRExcQ/5/VAyfn8OmlXpiC191WrXH5Uq8iXBw1 MHvw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=u6xr/fuUAw4R+YhTkYLa6tbcWlMca39fHqKFBsQm5nI=; b=ZCe2Mtvv0rgpEB82I9n6P3P2E3AWCk4KOXeS1agMEHD9tLM2n9r4TASNeQOkiB93Iv agzRRYiE5ev5BY1wJ2cgCkUyzns6Agn3bQTcrw3JzsplSKRH1cqM286rQ7is4MbiMXrg r8UPJtyNHjpQ5S1Go7FYuc67HUho6MIQKvo1kibadLQm3OvH1tHFodnKn5v2YeUp3uTB B3sNAHmJWQdKQrZdF3Cuyp0QP9o6mZ2DpFaT2xFDBmIlkX2Kk0Nas99wUq4hbaQij/NV YAYqwBEMz74XAlqopQPaLWaeNitiZtpWQHCXwDRkRvLHYETx0obV2CWkLAtzfk+YEVkb 4sCw== X-Gm-Message-State: AHQUAuaWg/QJpB5b0B2tdQT67KBCx3W683ioibxOtLKv7Z4GToD4YLWM 1l6xqvqmhfQF9VjhBis1khglEOOP X-Google-Smtp-Source: AHgI3IYTKsNBx1pFF+BamaKLyEpHMPtDNIBtyuuwoSExaoXga5vEsI6NFJEFpedaKpHweDrP5qASXg== X-Received: by 2002:a62:5003:: with SMTP id e3mr20334360pfb.23.1550420896607; Sun, 17 Feb 2019 08:28:16 -0800 (PST) Received: from tomato.housegordon.com (moose.housegordon.com. [184.68.105.38]) by smtp.googlemail.com with ESMTPSA id c124sm15758837pfb.3.2019.02.17.08.28.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 17 Feb 2019 08:28:15 -0800 (PST) References: <87mumxf6xn.fsf@jidanni.org> <49916778-4758-d040-5fcc-6e277a2dc183@redhat.com> <5b729a22-c3fa-b2b8-f204-ef27ed3a7292@gmail.com> From: Assaf Gordon Message-ID: <17f89f02-d446-d964-ffd4-2aae65b411a9@gmail.com> Date: Sun, 17 Feb 2019 09:28:14 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.4.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Spam-Score: -0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) On 2019-02-16 4:56 p.m., Bernhard Voelker wrote: > On 2/15/19 10:40 PM, Assaf Gordon wrote: >>> $ seq 9999 | env --default-signal PIPE sort -n | sed 5q | wc -l >> src/env.c | 90 +++++++++++++++++++++++++++++++++++++++- > > That's quite a lot of new code. > > What about a new program ... quick shot (and maybe an unlucky name): 'trap' ? > I don't mind either way (env feature or new program). "trap" will get mixed-up with the shell's built-in command. How about "untrap" (because the goal is to undo the 'trap' command), and also there's no "untrap" executable name in debian, so no name conflicts? will send an updated patch later today. -assaf From unknown Sun Jun 15 01:09:57 2025 X-Loop: help-debbugs@gnu.org Subject: bug#34488: Add sort --limit, or document workarounds for sort|head error messages Resent-From: Paul Eggert Original-Sender: "Debbugs-submit" Resent-CC: bug-coreutils@gnu.org Resent-Date: Sun, 17 Feb 2019 20:13:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 34488 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: To: Assaf Gordon , Bernhard Voelker , Eric Blake , =?UTF-8?Q?=E7=A9=8D=E4=B8=B9=E5=B0=BC?= Dan Jacobson , 34488@debbugs.gnu.org Received: via spool by 34488-submit@debbugs.gnu.org id=B34488.155043437832019 (code B ref 34488); Sun, 17 Feb 2019 20:13:02 +0000 Received: (at 34488) by debbugs.gnu.org; 17 Feb 2019 20:12:58 +0000 Received: from localhost ([127.0.0.1]:51687 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gvSo6-0008KN-B5 for submit@debbugs.gnu.org; Sun, 17 Feb 2019 15:12:58 -0500 Received: from zimbra.cs.ucla.edu ([131.179.128.68]:59858) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gvSo3-0008K9-D4 for 34488@debbugs.gnu.org; Sun, 17 Feb 2019 15:12:56 -0500 Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id AA3ED16138E; Sun, 17 Feb 2019 12:12:49 -0800 (PST) Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id BZ3FmCv_WB-1; Sun, 17 Feb 2019 12:12:49 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 024A1161397; Sun, 17 Feb 2019 12:12:49 -0800 (PST) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id fQmXCGthO2GG; Sun, 17 Feb 2019 12:12:48 -0800 (PST) Received: from [192.168.1.9] (cpe-23-242-74-103.socal.res.rr.com [23.242.74.103]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id B90EA161365; Sun, 17 Feb 2019 12:12:48 -0800 (PST) References: <87mumxf6xn.fsf@jidanni.org> <49916778-4758-d040-5fcc-6e277a2dc183@redhat.com> <5b729a22-c3fa-b2b8-f204-ef27ed3a7292@gmail.com> <17f89f02-d446-d964-ffd4-2aae65b411a9@gmail.com> From: Paul Eggert Organization: UCLA Computer Science Department Message-ID: <2d93c9af-d335-21b4-77c2-071532e32c66@cs.ucla.edu> Date: Sun, 17 Feb 2019 12:12:48 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.4.0 MIME-Version: 1.0 In-Reply-To: <17f89f02-d446-d964-ffd4-2aae65b411a9@gmail.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Assaf Gordon wrote: > I don't mind either way (env feature or new program). This should be a new feature of 'nohup' not 'env', as 'nohup' is already about signal handling. I don't see a need for a new program. From unknown Sun Jun 15 01:09:57 2025 X-Loop: help-debbugs@gnu.org Subject: bug#34488: Add sort --limit, or document workarounds for sort|head error messages Resent-From: Assaf Gordon Original-Sender: "Debbugs-submit" Resent-CC: bug-coreutils@gnu.org Resent-Date: Sun, 17 Feb 2019 20:32:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 34488 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: To: Paul Eggert , Bernhard Voelker , Eric Blake , =?UTF-8?Q?=E7=A9=8D=E4=B8=B9=E5=B0=BC?= Dan Jacobson , 34488@debbugs.gnu.org Received: via spool by 34488-submit@debbugs.gnu.org id=B34488.15504354971386 (code B ref 34488); Sun, 17 Feb 2019 20:32:02 +0000 Received: (at 34488) by debbugs.gnu.org; 17 Feb 2019 20:31:37 +0000 Received: from localhost ([127.0.0.1]:51699 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gvT69-0000MI-9F for submit@debbugs.gnu.org; Sun, 17 Feb 2019 15:31:37 -0500 Received: from mail-pf1-f182.google.com ([209.85.210.182]:40534) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gvT67-0000M5-EC for 34488@debbugs.gnu.org; Sun, 17 Feb 2019 15:31:35 -0500 Received: by mail-pf1-f182.google.com with SMTP id h1so7441593pfo.7 for <34488@debbugs.gnu.org>; Sun, 17 Feb 2019 12:31:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language:content-transfer-encoding; bh=fBcgJvkPxFN8CUa55S1n/lcoEcdlx/Zdnc0gNP1tfMI=; b=PuxR5oUXZuEEBCdkRl8maP2YicKnQaCcr3CNf+xB5z6rkEaY9IFF6gXHUbxVDQw8SY RUEw0gB1LFVM8JHeR/CxjHlxXxAcKzpLjmz30blJ7PYzfF+0HxlOEbbnkPj4qTNEokNd LBX/b3EqvXSp8IrMcpnD+TzCl1IzeGO13WztvUusrd664O6gsWCvHho1IFzaCYB4MuUj XEFNywwRYqiNIVkltJa6IUzyG7SCUlex9szfD+NLIWXxQjAau/nJc2sRKzk9OjFb0RKR 8VlylpDOwLTGxzqE0jSXxlvJ3oncDvOWGvidTMvM0DXhWcBEiMA3arnfpYj0m6NKUQGX nMcw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=fBcgJvkPxFN8CUa55S1n/lcoEcdlx/Zdnc0gNP1tfMI=; b=nM3MscT15Xr8o0OfXelBi0HgcFTrv1uDkxrftORwwmUcxTm1FoiCjSBlY1G3WaXbTZ iqq1lkNacPjoEXjRZ1/Hm+ipvyPO0jyo0qFETOePmdG6FVFQrx8OI9yvbA+vYUzTWqmb 34F5z7yFHKBbcLMF2HRUcFiSly5OE6WSb+8NcUHADWyLhf/7c09158S6hm9AS1ow46Mc FtLx9afJDFR7/ze58KCr3YFgtMW85vdQJQfkZarzeMsjMfLipFTbIz7Hc1GayMOiBZPH MPc/b8WTUpUSN/5kQ53q9moe2NC/V7PGeg+KLNerCvqyD0RZ7POPdMr9In+i2xelaAo2 eBoQ== X-Gm-Message-State: AHQUAuYPJabHnQjWw3Wd5gmvUWVyS87fcNU8IBLvcha4I41zITnIwtVP Ox008HVCzN9HJns18h6Xscp/A7RS X-Google-Smtp-Source: AHgI3Iaj2s+LcONNKVRciHhIay5xs0TTMMkUGgDJxTZiAx037Bokkc8L9T2LNMQKrnNlwFKo747ltg== X-Received: by 2002:a65:6496:: with SMTP id e22mr15357847pgv.7.1550435488827; Sun, 17 Feb 2019 12:31:28 -0800 (PST) Received: from tomato.housegordon.com (moose.housegordon.com. [184.68.105.38]) by smtp.googlemail.com with ESMTPSA id v6sm10748556pfb.149.2019.02.17.12.31.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 17 Feb 2019 12:31:27 -0800 (PST) References: <87mumxf6xn.fsf@jidanni.org> <49916778-4758-d040-5fcc-6e277a2dc183@redhat.com> <5b729a22-c3fa-b2b8-f204-ef27ed3a7292@gmail.com> <17f89f02-d446-d964-ffd4-2aae65b411a9@gmail.com> <2d93c9af-d335-21b4-77c2-071532e32c66@cs.ucla.edu> From: Assaf Gordon Message-ID: <5b099892-8773-2794-b8f3-437c79a65a5f@gmail.com> Date: Sun, 17 Feb 2019 13:31:26 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.4.0 MIME-Version: 1.0 In-Reply-To: <2d93c9af-d335-21b4-77c2-071532e32c66@cs.ucla.edu> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Hello, On 2019-02-17 1:12 p.m., Paul Eggert wrote: > Assaf Gordon wrote: >> I don't mind either way (env feature or new program). > > This should be a new feature of 'nohup' not 'env', as 'nohup' is already > about signal handling.  I don't see a need for a new program. With 'nohup' I don't think there will be an easy (or at least intuitive way) to 'untrap' SIGPIPE without affecting the output: STDOUT will be redirected to 'nohup.out' automatically (unless we add more options like "--no-redirect"). Example: env -C /foo/bar PROGRAM ## only change directory env --default-signal=PIPE PROGRAM ## only untrap SIGPIPE env -i PROGRAM ## only empty environment but nohup --default-signal=PIPE PROGRAM Will untrap SIGPIPE *and* SIGHUP *and* redirect stdout to a file. So we'll need to add: nohup --no-redirect-stdout --default-signal=PIPE PROGRAM Also, nohup's manual pages warns: "NOTE: your shell may have its own version of nohup, which usually supersedes the version described here. Please refer to your shell's documentation for details about the options it supports." And if there is a built-in "nohup", it will confuse users who want to use our new feature (and then more support questions, and we have to explain how to use "env nohup" or "\nohup". What do you think? -assaf From unknown Sun Jun 15 01:09:57 2025 X-Loop: help-debbugs@gnu.org Subject: bug#34488: Add sort --limit, or document workarounds for sort|head error messages Resent-From: Paul Eggert Original-Sender: "Debbugs-submit" Resent-CC: bug-coreutils@gnu.org Resent-Date: Sun, 17 Feb 2019 21:01:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 34488 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: To: Assaf Gordon , Bernhard Voelker , Eric Blake , =?UTF-8?Q?=E7=A9=8D=E4=B8=B9=E5=B0=BC?= Dan Jacobson , 34488@debbugs.gnu.org Received: via spool by 34488-submit@debbugs.gnu.org id=B34488.15504372354245 (code B ref 34488); Sun, 17 Feb 2019 21:01:02 +0000 Received: (at 34488) by debbugs.gnu.org; 17 Feb 2019 21:00:35 +0000 Received: from localhost ([127.0.0.1]:51775 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gvTYA-00016P-NX for submit@debbugs.gnu.org; Sun, 17 Feb 2019 16:00:34 -0500 Received: from zimbra.cs.ucla.edu ([131.179.128.68]:36074) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gvTY8-00016A-7X for 34488@debbugs.gnu.org; Sun, 17 Feb 2019 16:00:33 -0500 Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 0B17016139F; Sun, 17 Feb 2019 13:00:26 -0800 (PST) Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id e16DfMKCVGcP; Sun, 17 Feb 2019 13:00:25 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 47D3A16138C; Sun, 17 Feb 2019 13:00:25 -0800 (PST) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id momyvEf5dpow; Sun, 17 Feb 2019 13:00:25 -0800 (PST) Received: from [192.168.1.9] (cpe-23-242-74-103.socal.res.rr.com [23.242.74.103]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id 0D956161217; Sun, 17 Feb 2019 13:00:25 -0800 (PST) References: <87mumxf6xn.fsf@jidanni.org> <49916778-4758-d040-5fcc-6e277a2dc183@redhat.com> <5b729a22-c3fa-b2b8-f204-ef27ed3a7292@gmail.com> <17f89f02-d446-d964-ffd4-2aae65b411a9@gmail.com> <2d93c9af-d335-21b4-77c2-071532e32c66@cs.ucla.edu> <5b099892-8773-2794-b8f3-437c79a65a5f@gmail.com> From: Paul Eggert Organization: UCLA Computer Science Department Message-ID: <73fbf04f-c237-6a5a-584d-8152cc079f09@cs.ucla.edu> Date: Sun, 17 Feb 2019 13:00:24 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.4.0 MIME-Version: 1.0 In-Reply-To: <5b099892-8773-2794-b8f3-437c79a65a5f@gmail.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) You make good points about nohup. Still, it's too bad that we'd have to add a new command for such a trivial thing. Perhaps it'd be better to overload 'env' instead, as you proposed earlier. After all, env is already being used for another little environmental thing (namely changing directories), and if we find future needs for yet other little things (running with a different umask, say) we can put them under 'env' as well. From unknown Sun Jun 15 01:09:57 2025 X-Loop: help-debbugs@gnu.org Subject: bug#34488: Add sort --limit, or document workarounds for sort|head error messages Resent-From: =?UTF-8?Q?P=C3=A1draig?= Brady Original-Sender: "Debbugs-submit" Resent-CC: bug-coreutils@gnu.org Resent-Date: Mon, 18 Feb 2019 01:53:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 34488 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: To: Paul Eggert , Assaf Gordon , Bernhard Voelker , Eric Blake , =?UTF-8?Q?=E7=A9=8D=E4=B8=B9=E5=B0=BC?= Dan Jacobson , 34488@debbugs.gnu.org Received: via spool by 34488-submit@debbugs.gnu.org id=B34488.155045472931341 (code B ref 34488); Mon, 18 Feb 2019 01:53:01 +0000 Received: (at 34488) by debbugs.gnu.org; 18 Feb 2019 01:52:09 +0000 Received: from localhost ([127.0.0.1]:51890 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gvY6K-00089R-Mi for submit@debbugs.gnu.org; Sun, 17 Feb 2019 20:52:08 -0500 Received: from mail.magicbluesmoke.com ([82.195.144.49]:51770) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gvY6J-00089J-33 for 34488@debbugs.gnu.org; Sun, 17 Feb 2019 20:52:07 -0500 Received: from localhost.localdomain (unknown [76.21.115.186]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.magicbluesmoke.com (Postfix) with ESMTPSA id B6505989D; Mon, 18 Feb 2019 01:52:04 +0000 (GMT) References: <87mumxf6xn.fsf@jidanni.org> <49916778-4758-d040-5fcc-6e277a2dc183@redhat.com> <5b729a22-c3fa-b2b8-f204-ef27ed3a7292@gmail.com> <17f89f02-d446-d964-ffd4-2aae65b411a9@gmail.com> <2d93c9af-d335-21b4-77c2-071532e32c66@cs.ucla.edu> <5b099892-8773-2794-b8f3-437c79a65a5f@gmail.com> <73fbf04f-c237-6a5a-584d-8152cc079f09@cs.ucla.edu> From: =?UTF-8?Q?P=C3=A1draig?= Brady Message-ID: <514735cd-d8de-7f5d-f588-3c15856f1cdc@draigBrady.com> Date: Sun, 17 Feb 2019 17:52:02 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 In-Reply-To: <73fbf04f-c237-6a5a-584d-8152cc079f09@cs.ucla.edu> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) On 17/02/19 13:00, Paul Eggert wrote: > You make good points about nohup. Still, it's too bad that we'd have to add a > new command for such a trivial thing. > > Perhaps it'd be better to overload 'env' instead, as you proposed earlier. After > all, env is already being used for another little environmental thing (namely > changing directories), and if we find future needs for yet other little things > (running with a different umask, say) we can put them under 'env' as well. +1 From unknown Sun Jun 15 01:09:57 2025 X-Loop: help-debbugs@gnu.org Subject: bug#34488: Add sort --limit, or document workarounds for sort|head error messages Resent-From: =?UTF-8?Q?P=C3=A1draig?= Brady Original-Sender: "Debbugs-submit" Resent-CC: bug-coreutils@gnu.org Resent-Date: Mon, 18 Feb 2019 01:54:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 34488 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: To: =?UTF-8?Q?=E7=A9=8D=E4=B8=B9=E5=B0=BC?= Dan Jacobson , Bernhard Voelker Cc: 34488@debbugs.gnu.org, Assaf Gordon , Eric Blake Received: via spool by 34488-submit@debbugs.gnu.org id=B34488.155045483531539 (code B ref 34488); Mon, 18 Feb 2019 01:54:02 +0000 Received: (at 34488) by debbugs.gnu.org; 18 Feb 2019 01:53:55 +0000 Received: from localhost ([127.0.0.1]:51894 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gvY83-0008Cc-2O for submit@debbugs.gnu.org; Sun, 17 Feb 2019 20:53:55 -0500 Received: from mail.magicbluesmoke.com ([82.195.144.49]:51782) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gvY81-0008CU-JC for 34488@debbugs.gnu.org; Sun, 17 Feb 2019 20:53:53 -0500 Received: from localhost.localdomain (unknown [76.21.115.186]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.magicbluesmoke.com (Postfix) with ESMTPSA id 17DFA98DD; Mon, 18 Feb 2019 01:53:51 +0000 (GMT) References: <87mumxf6xn.fsf@jidanni.org> <49916778-4758-d040-5fcc-6e277a2dc183@redhat.com> <5b729a22-c3fa-b2b8-f204-ef27ed3a7292@gmail.com> <87wolyswqx.fsf@jidanni.org> From: =?UTF-8?Q?P=C3=A1draig?= Brady Message-ID: <75bcf090-9e99-c315-4f84-28fb8e655936@draigBrady.com> Date: Sun, 17 Feb 2019 17:53:48 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 In-Reply-To: <87wolyswqx.fsf@jidanni.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) On 16/02/19 23:24, 積丹尼 Dan Jacobson wrote: > (I recall I heard about 50 years ago when pipe buffers first came to > Unix they were supposed to be invisible to the user...) Right. A lot of folks don't understand/handle them fully though: https://www.pixelbeat.org/programming/sigpipe_handling.html From unknown Sun Jun 15 01:09:57 2025 X-Loop: help-debbugs@gnu.org Subject: bug#34488: Add sort --limit, or document workarounds for sort|head error messages Resent-From: =?UTF-8?Q?P=C3=A1draig?= Brady Original-Sender: "Debbugs-submit" Resent-CC: bug-coreutils@gnu.org Resent-Date: Mon, 18 Feb 2019 02:01:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 34488 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: To: Eric Blake , Assaf Gordon , =?UTF-8?Q?=E7=A9=8D=E4=B8=B9=E5=B0=BC?= Dan Jacobson , 34488@debbugs.gnu.org Received: via spool by 34488-submit@debbugs.gnu.org id=B34488.155045525532219 (code B ref 34488); Mon, 18 Feb 2019 02:01:01 +0000 Received: (at 34488) by debbugs.gnu.org; 18 Feb 2019 02:00:55 +0000 Received: from localhost ([127.0.0.1]:51898 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gvYEo-0008Na-TK for submit@debbugs.gnu.org; Sun, 17 Feb 2019 21:00:55 -0500 Received: from mail.magicbluesmoke.com ([82.195.144.49]:51796) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gvYEn-0008NS-FC for 34488@debbugs.gnu.org; Sun, 17 Feb 2019 21:00:53 -0500 Received: from localhost.localdomain (unknown [76.21.115.186]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.magicbluesmoke.com (Postfix) with ESMTPSA id 0F81799A6; Mon, 18 Feb 2019 02:00:50 +0000 (GMT) References: <87mumxf6xn.fsf@jidanni.org> <49916778-4758-d040-5fcc-6e277a2dc183@redhat.com> <5b729a22-c3fa-b2b8-f204-ef27ed3a7292@gmail.com> <4d4f04f0-8fae-5dd9-8f96-ad693b3f5388@redhat.com> From: =?UTF-8?Q?P=C3=A1draig?= Brady Message-ID: Date: Sun, 17 Feb 2019 18:00:49 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 In-Reply-To: <4d4f04f0-8fae-5dd9-8f96-ad693b3f5388@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) On 15/02/19 14:11, Eric Blake wrote: > On 2/15/19 3:40 PM, Assaf Gordon wrote: >> Helo, >> >> On 2019-02-15 8:20 a.m., Eric Blake wrote: >>> On 2/15/19 8:43 AM, 積丹尼 Dan Jacobson wrote: >>>> sort: write failed: 'standard output': Broken pipe >>>> sort: write error >> [...] >>> Perhaps coreutils should teach 'env' a command-line option to forcefully >>> reset SIGPIPE back to default behavior [...] If we >>> did that, then even if your sh is started with SIGPIPE ignored (so that >>> the shell itself can't restore default behavior), you could do this >>> theoretical invocation: >>> >>> $ seq 9999 | env --default-signal PIPE sort -n | sed 5q | wc -l >>> 5 >> >> That is a nice idea, I could've used it myself couple of times. >> >> Attached a suggested patch. >> If this seems like a good direction, I'll complete it with NEWS/docs/etc. > > Would we also want an easy way to ignore signals? That's a bit less of > an issue, since you can use 'trap "" $SIG' in the shell; but having the > symmetry in env may be nice (especially since using 'trap' is asymmetric > in that you can't force the shell to un-ignore an inherited ignored signal). I agree that ignore would be nice to add also. >> Usage is: >> env --default-signal=PIPE >> env -P ##shortcut to reset SIGPIPE BSD has -P for different reasons, so I would avoid that conflict thanks a lot for working on this guys. Pádraig From unknown Sun Jun 15 01:09:57 2025 X-Loop: help-debbugs@gnu.org Subject: bug#34488: Add sort --limit, or document workarounds for sort|head error messages Resent-From: =?UTF-8?Q?P=C3=A1draig?= Brady Original-Sender: "Debbugs-submit" Resent-CC: bug-coreutils@gnu.org Resent-Date: Mon, 18 Feb 2019 02:21:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 34488 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: To: Eric Blake , =?UTF-8?Q?=E7=A9=8D=E4=B8=B9=E5=B0=BC?= Dan Jacobson , 34488@debbugs.gnu.org Received: via spool by 34488-submit@debbugs.gnu.org id=B34488.15504564261596 (code B ref 34488); Mon, 18 Feb 2019 02:21:02 +0000 Received: (at 34488) by debbugs.gnu.org; 18 Feb 2019 02:20:26 +0000 Received: from localhost ([127.0.0.1]:51907 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gvYXh-0000Pf-Up for submit@debbugs.gnu.org; Sun, 17 Feb 2019 21:20:26 -0500 Received: from mail.magicbluesmoke.com ([82.195.144.49]:51864) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gvYXf-0000PW-Cq for 34488@debbugs.gnu.org; Sun, 17 Feb 2019 21:20:23 -0500 Received: from localhost.localdomain (unknown [76.21.115.186]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.magicbluesmoke.com (Postfix) with ESMTPSA id AC7EE9BD3; Mon, 18 Feb 2019 02:20:21 +0000 (GMT) References: <87mumxf6xn.fsf@jidanni.org> <49916778-4758-d040-5fcc-6e277a2dc183@redhat.com> From: =?UTF-8?Q?P=C3=A1draig?= Brady Message-ID: <4c48e648-d890-ab12-a364-d5b88b0f2903@draigBrady.com> Date: Sun, 17 Feb 2019 18:20:19 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 In-Reply-To: <49916778-4758-d040-5fcc-6e277a2dc183@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) On 15/02/19 07:20, Eric Blake wrote: > Except that POSIX has the nasty requirement that sh started with an > inherited ignored SIGPIPE must silently ignore all attempts from within > the shell to restore SIGPIPE handling to child processes of the shell: > > $ (trap '' PIPE; bash -c 'trap - PIPE; \ > seq 9999 | sort -n | sed 5q | wc -l') > 5 > sort: write failed: 'standard output': Broken pipe > sort: write error > You HAVE to use some other intermediate program if you want to override > an inherited ignored SIGPIPE in sh into an inherited default-behavior > SIGPIPE in sort. Should we also propose to POSIX to allow trap to specify default? Maybe `trap 0 PIPE` or similar? From unknown Sun Jun 15 01:09:57 2025 X-Loop: help-debbugs@gnu.org Subject: bug#34488: Add sort --limit, or document workarounds for sort|head error messages Resent-From: Assaf Gordon Original-Sender: "Debbugs-submit" Resent-CC: bug-coreutils@gnu.org Resent-Date: Mon, 18 Feb 2019 09:48:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 34488 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: To: =?UTF-8?Q?P=C3=A1draig?= Brady , Paul Eggert , Bernhard Voelker , Eric Blake , =?UTF-8?Q?=E7=A9=8D=E4=B8=B9=E5=B0=BC?= Dan Jacobson , 34488@debbugs.gnu.org Received: via spool by 34488-submit@debbugs.gnu.org id=B34488.155048324111395 (code B ref 34488); Mon, 18 Feb 2019 09:48:02 +0000 Received: (at 34488) by debbugs.gnu.org; 18 Feb 2019 09:47:21 +0000 Received: from localhost ([127.0.0.1]:52102 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gvfW5-0002xb-3r for submit@debbugs.gnu.org; Mon, 18 Feb 2019 04:47:21 -0500 Received: from mail-pf1-f178.google.com ([209.85.210.178]:41838) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gvfW1-0002xK-PI for 34488@debbugs.gnu.org; Mon, 18 Feb 2019 04:47:11 -0500 Received: by mail-pf1-f178.google.com with SMTP id b7so8282303pfi.8 for <34488@debbugs.gnu.org>; Mon, 18 Feb 2019 01:47:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language; bh=c9woJCdrSQH5GvCw7adjpvH4h7IEhTj1l3a5DgDGKpM=; b=smaVPW8r32mDzC5Z3rpOdxfE3rwMTPq/R+Ev9h/03qMH+uqNQn5HB/NIURhNXvjpNw j6gqlKkLTSVSQ6HRlqSZUcJWwTiUmjJ17/VhAE0fxlJFGuvKq6gU9D+lPjck2V3i7Jnb K7zkV0+yGfeWvgXwi2tD/ZR1cf75sJDOXvme7540Sw13ZaXgj3JOLdqxXGZgiDHq6A2S R0dQ+T7MgbWFnMBZh9rZa729/teYSiS399K1tJoDp877/Cs+ES4nJV+FVoU8mn/salT5 JOyzbf8FK6H+9ym+mLqJfHHxKjjmv7QXMme5BtLweUTvbjgRZg+QLJPjYWB6yDGsybzr RixA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language; bh=c9woJCdrSQH5GvCw7adjpvH4h7IEhTj1l3a5DgDGKpM=; b=JNNPBjuJaYHkVcG+NW6xygM5FaUa1j95OOeCbsTXfmjUOBr+4SxwNvlF70fuX6i82V fL7ieAIH9AKsGEcLeKvT8DiLttPa92f+KLoyAMJ+EHNZA2PMkF68VQ6VbizQ/4cjfOjd SwkR5yBv1K75dQgc5BxJTtlcEQZJ6vb7qI95GPCbs9qYGcfSMgo9Qj/5GvtoRusgN1KT yMDHr+qZSYxfTLSphuKC0T81q/vplrZeUQlBYciLAa7m6SVPrv+K600+hDK780ruAq+4 6OeP+GwtLGXyttyjKiaKlfsw1AI0EfiVk7N+0PuksFeLklL8zDPfvUpLV6WmRwQ39oYY bkpQ== X-Gm-Message-State: AHQUAuYZhIwmmm7ughLNZPGhx1Z3sZvfBduYslazg8MeJPVEMRHzZG5o eMcht8l666I90cExEqdEkgrfm+i/ X-Google-Smtp-Source: AHgI3Ib3H/XlCIL4EiDdvqR2W1XL0c5WPjw1JaV3f4mQQhVvOkEAKWF58s7u/+fro1IAS5LZzIJPsw== X-Received: by 2002:a63:d54a:: with SMTP id v10mr18064412pgi.154.1550483223022; Mon, 18 Feb 2019 01:47:03 -0800 (PST) Received: from tomato.housegordon.com (moose.housegordon.com. [184.68.105.38]) by smtp.googlemail.com with ESMTPSA id d3sm38487142pfj.54.2019.02.18.01.47.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 18 Feb 2019 01:47:00 -0800 (PST) References: <87mumxf6xn.fsf@jidanni.org> <49916778-4758-d040-5fcc-6e277a2dc183@redhat.com> <5b729a22-c3fa-b2b8-f204-ef27ed3a7292@gmail.com> <17f89f02-d446-d964-ffd4-2aae65b411a9@gmail.com> <2d93c9af-d335-21b4-77c2-071532e32c66@cs.ucla.edu> <5b099892-8773-2794-b8f3-437c79a65a5f@gmail.com> <73fbf04f-c237-6a5a-584d-8152cc079f09@cs.ucla.edu> <514735cd-d8de-7f5d-f588-3c15856f1cdc@draigBrady.com> From: Assaf Gordon Message-ID: <683b367c-2b3b-1869-af8c-40d5a77370c3@gmail.com> Date: Mon, 18 Feb 2019 02:46:59 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.4.0 MIME-Version: 1.0 In-Reply-To: <514735cd-d8de-7f5d-f588-3c15856f1cdc@draigBrady.com> Content-Type: multipart/mixed; boundary="------------8C75335AA9753A7A822E13E8" Content-Language: en-US X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) This is a multi-part message in MIME format. --------------8C75335AA9753A7A822E13E8 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Hello, Thanks for all comments (on and off list). Attached an updated patch with documentation. The supported options are: --default-signal[=SIG] reset signal SIG to its default signal handler. without SIG, all known signals are included. multiple signals can be comma-separated. --ignore-signal[=SIG] set signal SIG to be IGNORED. without SIG, all known signals are included. multiple signals can be comma-separated. -p same as --default-signal=PIPE (lower-case "-p" as to not conflict with BSD, but of course can be changed to another letter). The new 'env-signal-handler.sh' test passes on GNU/linux, non-gnu/linux (alpine), and Free/Open/Net BSD. Comments very welcomed, - assaf --------------8C75335AA9753A7A822E13E8 Content-Type: text/x-patch; name="0001-env-new-options-p-default-signal-SIG-ignore-signal-S.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0001-env-new-options-p-default-signal-SIG-ignore-signal-S.pa"; filename*1="tch" >From 3542f1762c9f14e2275fe5e61d5d7f6275b420a9 Mon Sep 17 00:00:00 2001 From: Assaf Gordon Date: Fri, 15 Feb 2019 12:31:48 -0700 Subject: [PATCH] env: new options -p/--default-signal=SIG/--ignore-signal=SIG New options to set signal handlers to default (SIG_DFL) or ignore (SIG_IGN) This is useful to overcome POSIX limitation that shell must not override inherited signal state, e.g. the second 'trap' here is a no-op: trap '' PIPE && sh -c 'trap - PIPE ; seq inf | head -n1' Instead use: trap '' PIPE && sh -c 'env -p seq inf | head -n1' Similarly, the following will prevent CTRL-C from terminating the program: env --ignore-signal=INT seq inf > /dev/null See https://bugs.gnu.org/34488#8 . * NEWS: Mention new options. * doc/coreutils.texi (env invocation): Document new options. * man/env.x: Add example of --default-signal=SIG usage. * src/env.c (signals): New global variable. (shortopts,longopts): Add new options. (usage): Print new options. (parse_signal_params): Parse comma-separated list of signals, store in signals variable. (reset_signal_handlers): Set each signal to SIG_DFL/SIG_IGN. (main): Process new options. * src/local.mk (src_env_SOURCES): Add operand2sig.c. * tests/misc/env-signal-handler.sh: New test. * tests/local.mk (all_tests): Add new test. --- NEWS | 3 + doc/coreutils.texi | 43 ++++++++++++ man/env.x | 35 ++++++++++ src/env.c | 127 +++++++++++++++++++++++++++++++++- src/local.mk | 1 + tests/local.mk | 1 + tests/misc/env-signal-handler.sh | 146 +++++++++++++++++++++++++++++++++++++++ 7 files changed, 355 insertions(+), 1 deletion(-) create mode 100755 tests/misc/env-signal-handler.sh diff --git a/NEWS b/NEWS index fdde47593..5a8e8a3de 100644 --- a/NEWS +++ b/NEWS @@ -67,6 +67,9 @@ GNU coreutils NEWS -*- outline -*- test now supports the '-N FILE' unary operator (like e.g. bash) to check whether FILE exists and has been modified since it was last read. + env now supports '--default-singal[=SIG]' and '--ignore-signal[=SIG]' + options to set signal handlers before executing a program. + ** New commands basenc is added to complement existing base64,base32 commands, diff --git a/doc/coreutils.texi b/doc/coreutils.texi index be35de490..57b209e07 100644 --- a/doc/coreutils.texi +++ b/doc/coreutils.texi @@ -17227,6 +17227,49 @@ chroot /chroot env --chdir=/srv true env --chdir=/build FOO=bar timeout 5 true @end example +@item --default-signal[=@var{sig}] +Reset signal @var{sig} to its default signal handler. Without @var{sig} all +known signals are reset to their defaults. Multiple signals can be +comma-separated. The following command runs @command{seq} with SIGINT and +SIGPIPE set to their default (which is to terminate the program): + +@example +env --default-signal=PIPE,INT seq 1000 | head -n1 +@end example + +In the following example: + +@example +trap '' PIPE && sh -c 'trap - PIPE ; seq inf | head -n1' +@end example + +The first trap command sets SIGPIPE to ignore. The second trap command +ostensibly sets it back to its default, but POSIX mandates that the shell +must not change inherited state of the signal - so it is a no-op. + +Using @option{--default-signal=PIPE} (or its shortcut @option{-p}) can be +used to force the signal to its default behavior: + +@example +trap '' PIPE && sh -c "env -p seq inf | head -n1' +@end example + + +@item --ignore-signal[=@var{sig}] +Ignore signal @var{sig} when running a program. Without @var{sig} all +known signals are set to ignore. Multiple signals can be +comma-separated. The following command runs @command{seq} with SIGINT set +to be ignored - pressing @kbd{Ctrl-C} will not terminate it: + +@example +env --ignore-signal=INT seq inf > /dev/null +@end example + + +@item -p +Equivalent to @option{--default-signal=PIPE} - sets SIGPIPE to its default +behavior (terminate a program upon SIGPIPE). + @item -v @itemx --debug @opindex -v diff --git a/man/env.x b/man/env.x index 8eea79655..5e0ef975e 100644 --- a/man/env.x +++ b/man/env.x @@ -37,3 +37,38 @@ parameter the script will likely fail with: .RE .PP See the full documentation for more details. +.PP +.SS "\-\-default-signal[=SIG]" to 'untrap' a singal +This option allows setting a signal handler to its default +action. This is useful to reset a signal after setting it +to 'ignore' using the shell's trap command. + +In the following example: +.PP +.RS +.nf +trap '' PIPE && sh \-c 'trap \- PIPE ; seq inf | head \-n1' +.fi +.RE +.PP +The first +.B trap +command sets SIGPIPE to ignore. +The second +.B trap +command ostensibly sets it back to its default, but POSIX mandates that the +shell must not change inherited state of the signal - so it is a no-op. +.PP +Using +.B \-\-default-signal=PIPE +(or its shortcut +.B \-p +) +can be used to force the signal to its default behavior: +.PP +.RS +.nf +trap '' PIPE && sh \-c "env \-p seq inf | head \-n1' +.fi +.RE +.PP diff --git a/src/env.c b/src/env.c index 3a1a3869e..6c20ac40c 100644 --- a/src/env.c +++ b/src/env.c @@ -21,12 +21,15 @@ #include #include #include +#include #include #include "system.h" #include "die.h" #include "error.h" +#include "operand2sig.h" #include "quote.h" +#include "sig2str.h" /* The official name of this program (e.g., no 'g' prefix). */ #define PROGRAM_NAME "env" @@ -48,7 +51,27 @@ static bool dev_debug; static char *varname; static size_t vnlen; -static char const shortopts[] = "+C:iS:u:v0 \t"; +/* Possible actions on each signal. */ +enum SIGNAL_MODE { + UNCHANGED = 0, + DEFAULT, /* Set to default handler (SIG_DFL). */ + DEFAULT_NOERR, /* ditto, but ignore sigaction(2) errors. */ + IGNORE, /* Set to ignore (SIG_IGN). */ + IGNORE_NOERR /* ditto, but ignore sigaction(2) errors. */ +}; +static enum SIGNAL_MODE signals[SIGNUM_BOUND]; + + + +static char const shortopts[] = "+C:ipS:u:v0 \t"; + +/* For long options that have no equivalent short option, use a + non-character as a pseudo short option, starting with CHAR_MAX + 1. */ +enum +{ + DEFAULT_SIGNAL_OPTION = CHAR_MAX + 1, + IGNORE_SIGNAL_OPTION +}; static struct option const longopts[] = { @@ -56,6 +79,8 @@ static struct option const longopts[] = {"null", no_argument, NULL, '0'}, {"unset", required_argument, NULL, 'u'}, {"chdir", required_argument, NULL, 'C'}, + {"default-signal", optional_argument, NULL, DEFAULT_SIGNAL_OPTION}, + {"ignore-signal", optional_argument, NULL, IGNORE_SIGNAL_OPTION}, {"debug", no_argument, NULL, 'v'}, {"split-string", required_argument, NULL, 'S'}, {GETOPT_HELP_OPTION_DECL}, @@ -88,8 +113,23 @@ Set each NAME to VALUE in the environment and run COMMAND.\n\ -C, --chdir=DIR change working directory to DIR\n\ "), stdout); fputs (_("\ + --default-signal[=SIG] reset signal SIG to its default signal handler.\n\ + without SIG, all known signals are included.\n\ + multiple signals can be comma-separated.\n\ +"), stdout); + fputs (_("\ + --ignore-signal[=SIG] set signal SIG to be IGNORED.\n\ + without SIG, all known signals are included.\n\ + multiple signals can be comma-separated.\n\ +"), stdout); + fputs (_("\ -S, --split-string=S process and split S into separate arguments;\n\ used to pass multiple arguments on shebang lines\n\ +"), stdout); + fputs (_("\ + -p same as --default-signal=PIPE\n\ +"), stdout); + fputs (_("\ -v, --debug print verbose information for each processing step\n\ "), stdout); fputs (HELP_OPTION_DESCRIPTION, stdout); @@ -525,6 +565,79 @@ parse_split_string (const char* str, int /*out*/ *orig_optind, *orig_optind = 0; /* tell getopt to restart from first argument */ } +static void +parse_signal_params (const char* optarg, bool set_default) +{ + char signame[SIG2STR_MAX]; + char *opt_sig; + char *optarg_writable; + + if (!optarg) + { + /* without an argument, reset all signals. + Some signals cannot be set to ignore or default (e.g., SIGKILL, + SIGSTOP on most OSes, and SIGCONT on AIX.) - so ignore errors. */ + for (int i = 0 ; i < SIGNUM_BOUND; ++i) + if (sig2str (i, signame) == 0) + signals[i] = set_default ? DEFAULT_NOERR : IGNORE_NOERR; + return; + } + + optarg_writable = xstrdup (optarg); + + opt_sig = strtok (optarg_writable, ","); + while (opt_sig) + { + int signum = operand2sig (opt_sig, signame); + if (signum < 0) + usage (exit_failure); + + signals[signum] = set_default ? DEFAULT : IGNORE; + + opt_sig = strtok (NULL, ","); + } + + free (optarg_writable); +} + +static void +reset_signal_handlers (void) +{ + for (int i=0; i. + +. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src +print_ver_ seq +print_ver_ timeout +print_ver_ test +trap_sigpipe_or_skip_ + +# Paraphrasing http://bugs.gnu.org/34488#8: +# POSIX requires that sh started with an inherited ignored SIGPIPE must +# silently ignore all attempts from within the shell to restore SIGPIPE +# handling to child processes of the shell: +# +# $ (trap '' PIPE; bash -c 'trap - PIPE; seq inf | head -n1') +# 1 +# seq: write error: Broken pipe +# +# With 'env --default-signal=PIPE', the signal handler can be reset to its +# default. + +# Baseline Test - default signal handler +# -------------------------------------- +# Ensure this results in a "broken pipe" error (the first 'trap' +# sets SIGPIPE to ignore, and the second 'trap' becomes a no-op instead +# of resetting SIGPIPE to its default). Upon a SIGPIPE 'seq' will not be +# terminated, instead its write(2) call will return an error. +(trap '' PIPE; sh -c 'trap - PIPE; seq 999999 2>err1t | head -n1 > out1') + +# The exact broken pipe message depends on the operating system, just ensure +# there was a 'write error' message in stderr: +sed 's/^\(seq: write error:\) .*/\1/' err1t > err1 || framework_failure_ + +printf "1\n" > exp-out || framework_failure_ +printf "seq: write error:\n" > exp-err1 || framework_failure_ + +compare exp-out out1 || framework_failure_ +compare exp-err1 err1 || framework_failure_ + + +# env test - default signal handler +# --------------------------------- +# With env resetting the signal handler to its defaults, there should be no +# error message (because the default SIGPIPE action is to terminate the +# 'seq' program): +(trap '' PIPE; + env --default-signal=PIPE \ + sh -c 'trap - PIPE; seq 999999 2>err2 | head -n1 > out2') + +compare exp-out out2 || fail=1 +compare /dev/null err2 || fail=1 + +# env test - default signal handler (2) +# ------------------------------------- +# Repeat the previous test, using "-p" (shortcut for --default-signal=PIPE): +(trap '' PIPE; + env -p \ + sh -c 'trap - PIPE; seq 999999 2>err3 | head -n1 > out3') + +compare exp-out out3 || fail=1 +compare /dev/null err3 || fail=1 + +# env test - default signal handler (3) +# ------------------------------------- +# Repeat the previous test, using --default-signal with no signal names, +# i.e., all signals. +(trap '' PIPE; + env --default-signal \ + sh -c 'trap - PIPE; seq 999999 2>err4 | head -n1 > out4') + +compare exp-out out4 || fail=1 +compare /dev/null err4 || fail=1 + + + + + + +# Baseline test - ignore signal handler +# ------------------------------------- +# Kill 'seq' after 1 second with SIGINT - it should terminate (as SIGINT's +# default action is to terminate a program). +# (The first 'env' is just to ensure timeout is not the shell's built-in.) +env timeout --verbose --kill-after=1 --signal=INT 1 \ + seq inf > /dev/null 2>err5 + +printf "timeout: sending signal INT to command 'seq'\n" > exp-err5 \ + || framework_failure_ + +compare exp-err5 err5 || fail=1 + + +# env test - ignore signal handler +# -------------------------------- +# Use env to silence (ignore) SIGINT - "seq" should continue running +# after timeout sends SIGINT, and be killed after 1 second using SIGKILL. + +cat>exp-err6 < /dev/null 2>err6t + +# check only the first two lines from stderr, which are printed by timeout. +# (operating systems might add more messages, like "killed"). +sed -n '1,2p' err6t > err6 || framework_failure_ + +compare exp-err6 err6 || fail=1 + + +# env test - ignore signal handler (2) +# ------------------------------------ +# Repeat the previous test with "--ignore-signals" and no signal names, +# i.e., all signals. + +env timeout --verbose --kill-after=1 --signal=INT 1 \ + env --ignore-signal \ + seq inf > /dev/null 2>err7t + +# check only the first two lines from stderr, which are printed by timeout. +# (operating systems might add more messages, like "killed"). +sed -n '1,2p' err7t > err7 || framework_failure_ + +compare exp-err6 err7 || fail=1 + + + +Exit $fail -- 2.11.0 --------------8C75335AA9753A7A822E13E8-- From unknown Sun Jun 15 01:09:57 2025 X-Loop: help-debbugs@gnu.org Subject: bug#34488: Add sort --limit, or document workarounds for sort|head error messages Resent-From: Eric Blake Original-Sender: "Debbugs-submit" Resent-CC: bug-coreutils@gnu.org Resent-Date: Mon, 18 Feb 2019 16:03:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 34488 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: To: =?UTF-8?Q?P=C3=A1draig?= Brady , =?UTF-8?Q?=E7=A9=8D=E4=B8=B9=E5=B0=BC?= Dan Jacobson , 34488@debbugs.gnu.org Received: via spool by 34488-submit@debbugs.gnu.org id=B34488.155050577423608 (code B ref 34488); Mon, 18 Feb 2019 16:03:02 +0000 Received: (at 34488) by debbugs.gnu.org; 18 Feb 2019 16:02:54 +0000 Received: from localhost ([127.0.0.1]:53107 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gvlNe-00068i-BH for submit@debbugs.gnu.org; Mon, 18 Feb 2019 11:02:54 -0500 Received: from mx1.redhat.com ([209.132.183.28]:54922) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gvlNa-00068T-Pk for 34488@debbugs.gnu.org; Mon, 18 Feb 2019 11:02:52 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id EAF1EC0740D5; Mon, 18 Feb 2019 16:02:44 +0000 (UTC) Received: from [10.3.116.222] (ovpn-116-222.phx2.redhat.com [10.3.116.222]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 550E160139; Mon, 18 Feb 2019 16:02:44 +0000 (UTC) References: <87mumxf6xn.fsf@jidanni.org> <49916778-4758-d040-5fcc-6e277a2dc183@redhat.com> <4c48e648-d890-ab12-a364-d5b88b0f2903@draigBrady.com> From: Eric Blake Openpgp: preference=signencrypt Autocrypt: addr=eblake@redhat.com; keydata= xsBNBEvHyWwBCACw7DwsQIh0kAbUXyqhfiKAKOTVu6OiMGffw2w90Ggrp4bdVKmCaEXlrVLU xphBM8mb+wsFkU+pq9YR621WXo9REYVIl0FxKeQo9dyQBZ/XvmUMka4NOmHtFg74nvkpJFCD TUNzmqfcjdKhfFV0d7P/ixKQeZr2WP1xMcjmAQY5YvQ2lUoHP43m8TtpB1LkjyYBCodd+LkV GmCx2Bop1LSblbvbrOm2bKpZdBPjncRNob73eTpIXEutvEaHH72LzpzksfcKM+M18cyRH+nP sAd98xIbVjm3Jm4k4d5oQyE2HwOur+trk2EcxTgdp17QapuWPwMfhaNq3runaX7x34zhABEB AAHNHkVyaWMgQmxha2UgPGVibGFrZUByZWRoYXQuY29tPsLAegQTAQgAJAIbAwULCQgHAwUV CgkICwUWAgMBAAIeAQIXgAUCS8fL9QIZAQAKCRCnoWtKJSdDahBHCACbl/5FGkUqJ89GAjeX RjpAeJtdKhujir0iS4CMSIng7fCiGZ0fNJCpL5RpViSo03Q7l37ss+No+dJI8KtAp6ID+PMz wTJe5Egtv/KGUKSDvOLYJ9WIIbftEObekP+GBpWP2+KbpADsc7EsNd70sYxExD3liwVJYqLc Rw7so1PEIFp+Ni9A1DrBR5NaJBnno2PHzHPTS9nmZVYm/4I32qkLXOcdX0XElO8VPDoVobG6 gELf4v/vIImdmxLh/w5WctUpBhWWIfQDvSOW2VZDOihm7pzhQodr3QP/GDLfpK6wI7exeu3P pfPtqwa06s1pae3ad13mZGzkBdNKs1HEm8x6zsBNBEvHyWwBCADGkMFzFjmmyqAEn5D+Mt4P zPdO8NatsDw8Qit3Rmzu+kUygxyYbz52ZO40WUu7EgQ5kDTOeRPnTOd7awWDQcl1gGBXgrkR pAlQ0l0ReO57Q0eglFydLMi5bkwYhfY+TwDPMh3aOP5qBXkm4qIYSsxb8A+i00P72AqFb9Q7 3weG/flxSPApLYQE5qWGSXjOkXJv42NGS6o6gd4RmD6Ap5e8ACo1lSMPfTpGzXlt4aRkBfvb NCfNsQikLZzFYDLbQgKBA33BDeV6vNJ9Cj0SgEGOkYyed4I6AbU0kIy1hHAm1r6+sAnEdIKj cHi3xWH/UPrZW5flM8Kqo14OTDkI9EtlABEBAAHCwF8EGAEIAAkFAkvHyWwCGwwACgkQp6Fr SiUnQ2q03wgAmRFGDeXzc58NX0NrDijUu0zx3Lns/qZ9VrkSWbNZBFjpWKaeL1fdVeE4TDGm I5mRRIsStjQzc2R9b+2VBUhlAqY1nAiBDv0Qnt+9cLiuEICeUwlyl42YdwpmY0ELcy5+u6wz mK/jxrYOpzXKDwLq5k4X+hmGuSNWWAN3gHiJqmJZPkhFPUIozZUCeEc76pS/IUN72NfprZmF Dp6/QDjDFtfS39bHSWXKVZUbqaMPqlj/z6Ugk027/3GUjHHr8WkeL1ezWepYDY7WSoXwfoAL 2UXYsMAr/uUncSKlfjvArhsej0S4zbqim2ZY6S8aRWw94J3bSvJR+Nwbs34GPTD4Pg== Organization: Red Hat, Inc. Message-ID: Date: Mon, 18 Feb 2019 10:02:40 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.5.0 MIME-Version: 1.0 In-Reply-To: <4c48e648-d890-ab12-a364-d5b88b0f2903@draigBrady.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="2CtKp3TgpksPAiiuwUTz5kZwaWOid72t6" X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Mon, 18 Feb 2019 16:02:45 +0000 (UTC) X-Spam-Score: -5.0 (-----) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -6.0 (------) This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --2CtKp3TgpksPAiiuwUTz5kZwaWOid72t6 Content-Type: multipart/mixed; boundary="4QWIas5PG7QpiFrI0THrtBalPqsZjKz9K"; protected-headers="v1" From: Eric Blake To: =?UTF-8?Q?P=c3=a1draig_Brady?= , =?UTF-8?B?56mN5Li55bC8IERhbiBKYWNvYnNvbg==?= , 34488@debbugs.gnu.org Message-ID: Subject: Re: bug#34488: Add sort --limit, or document workarounds for sort|head error messages References: <87mumxf6xn.fsf@jidanni.org> <49916778-4758-d040-5fcc-6e277a2dc183@redhat.com> <4c48e648-d890-ab12-a364-d5b88b0f2903@draigBrady.com> In-Reply-To: <4c48e648-d890-ab12-a364-d5b88b0f2903@draigBrady.com> --4QWIas5PG7QpiFrI0THrtBalPqsZjKz9K Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: quoted-printable On 2/17/19 8:20 PM, P=C3=A1draig Brady wrote: > On 15/02/19 07:20, Eric Blake wrote: >> Except that POSIX has the nasty requirement that sh started with an >> inherited ignored SIGPIPE must silently ignore all attempts from withi= n >> the shell to restore SIGPIPE handling to child processes of the shell:= >> >> $ (trap '' PIPE; bash -c 'trap - PIPE; \ >> seq 9999 | sort -n | sed 5q | wc -l') >> 5 >> sort: write failed: 'standard output': Broken pipe >> sort: write error >=20 >> You HAVE to use some other intermediate program if you want to overrid= e >> an inherited ignored SIGPIPE in sh into an inherited default-behavior >> SIGPIPE in sort. >=20 > Should we also propose to POSIX to allow trap to specify default? That's what "trap - PIPE" is already supposed to do, except that POSIX has the odd requirement that a signal that was inherited ignored cannot be reset to default. > Maybe `trap 0 PIPE` or similar? Alas, bash has already defined that to mean the same as 'trap - EXIT PIPE= '. --=20 Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3226 Virtualization: qemu.org | libvirt.org --4QWIas5PG7QpiFrI0THrtBalPqsZjKz9K-- --2CtKp3TgpksPAiiuwUTz5kZwaWOid72t6 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAEBCAAdFiEEccLMIrHEYCkn0vOqp6FrSiUnQ2oFAlxq1yEACgkQp6FrSiUn Q2pUAgf/Y0YNc0iOCNGqI+63RyWbbDAddCsry0qRPFzizOOcNOO6xJCCRU7gVVya 5FrXZeaWkjLqJYOgtJfCFacPm2j4/qq9N5cUuPJlrUBHY3N1ebxEIctv6Jshxk60 M9iN3u720G9wex38psua0mpCJ4mbjixkQpkmE55RQmZO1uPXqkANpIrSDkTRktbq TI8AxAhcFKeeWuDTnpdIkF/MiHcJowKqcf9z62FXqNisbRH4J4Dy9i5K5x9Hzvtd Kt8IHDx/P6MxQerVZ3ES5EsTiV4FQpBvit5awtBsIEw64Yu+zc+K5Srd50DLr6tZ WBjEwXhmwLMU6In0K3HgOggY4z4+VQ== =Vytu -----END PGP SIGNATURE----- --2CtKp3TgpksPAiiuwUTz5kZwaWOid72t6-- From unknown Sun Jun 15 01:09:57 2025 X-Loop: help-debbugs@gnu.org Subject: bug#34488: Add sort --limit, or document workarounds for sort|head error messages Resent-From: =?UTF-8?Q?P=C3=A1draig?= Brady Original-Sender: "Debbugs-submit" Resent-CC: bug-coreutils@gnu.org Resent-Date: Sun, 24 Feb 2019 05:33:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 34488 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: To: Eric Blake , =?UTF-8?Q?=E7=A9=8D=E4=B8=B9=E5=B0=BC?= Dan Jacobson , 34488@debbugs.gnu.org Received: via spool by 34488-submit@debbugs.gnu.org id=B34488.15509863289826 (code B ref 34488); Sun, 24 Feb 2019 05:33:02 +0000 Received: (at 34488) by debbugs.gnu.org; 24 Feb 2019 05:32:08 +0000 Received: from localhost ([127.0.0.1]:49754 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gxmOW-0002YQ-DY for submit@debbugs.gnu.org; Sun, 24 Feb 2019 00:32:08 -0500 Received: from mail.magicbluesmoke.com ([82.195.144.49]:58104) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gxmOU-0002YI-Mj for 34488@debbugs.gnu.org; Sun, 24 Feb 2019 00:32:07 -0500 Received: from localhost.localdomain (unknown [76.21.115.186]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.magicbluesmoke.com (Postfix) with ESMTPSA id EAF059B08; Sun, 24 Feb 2019 05:32:04 +0000 (GMT) References: <87mumxf6xn.fsf@jidanni.org> <49916778-4758-d040-5fcc-6e277a2dc183@redhat.com> <4c48e648-d890-ab12-a364-d5b88b0f2903@draigBrady.com> From: =?UTF-8?Q?P=C3=A1draig?= Brady Message-ID: Date: Sat, 23 Feb 2019 21:32:02 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) On 18/02/19 08:02, Eric Blake wrote: > On 2/17/19 8:20 PM, Pádraig Brady wrote: >> On 15/02/19 07:20, Eric Blake wrote: >>> Except that POSIX has the nasty requirement that sh started with an >>> inherited ignored SIGPIPE must silently ignore all attempts from within >>> the shell to restore SIGPIPE handling to child processes of the shell: >>> >>> $ (trap '' PIPE; bash -c 'trap - PIPE; \ >>> seq 9999 | sort -n | sed 5q | wc -l') >>> 5 >>> sort: write failed: 'standard output': Broken pipe >>> sort: write error >> >>> You HAVE to use some other intermediate program if you want to override >>> an inherited ignored SIGPIPE in sh into an inherited default-behavior >>> SIGPIPE in sort. >> >> Should we also propose to POSIX to allow trap to specify default? > > That's what "trap - PIPE" is already supposed to do, except that POSIX > has the odd requirement that a signal that was inherited ignored cannot > be reset to default. > >> Maybe `trap 0 PIPE` or similar? > > Alas, bash has already defined that to mean the same as 'trap - EXIT PIPE'. Fair enough, but do we agree that it would be good to have functionality in the shell with some similar syntax that resets the handler to system default? cheers, Pádraig From unknown Sun Jun 15 01:09:57 2025 X-Loop: help-debbugs@gnu.org Subject: bug#34488: Add sort --limit, or document workarounds for sort|head error messages Resent-From: =?UTF-8?Q?P=C3=A1draig?= Brady Original-Sender: "Debbugs-submit" Resent-CC: bug-coreutils@gnu.org Resent-Date: Sun, 24 Feb 2019 06:14:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 34488 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: To: Assaf Gordon , Paul Eggert , Bernhard Voelker , Eric Blake , =?UTF-8?Q?=E7=A9=8D=E4=B8=B9=E5=B0=BC?= Dan Jacobson , 34488@debbugs.gnu.org Received: via spool by 34488-submit@debbugs.gnu.org id=B34488.155098883413744 (code B ref 34488); Sun, 24 Feb 2019 06:14:02 +0000 Received: (at 34488) by debbugs.gnu.org; 24 Feb 2019 06:13:54 +0000 Received: from localhost ([127.0.0.1]:49764 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gxn2w-0003Zc-59 for submit@debbugs.gnu.org; Sun, 24 Feb 2019 01:13:54 -0500 Received: from mail.magicbluesmoke.com ([82.195.144.49]:32852) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gxn2u-0003ZT-1m for 34488@debbugs.gnu.org; Sun, 24 Feb 2019 01:13:52 -0500 Received: from localhost.localdomain (unknown [76.21.115.186]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.magicbluesmoke.com (Postfix) with ESMTPSA id 3DCBC9ECC; Sun, 24 Feb 2019 06:13:43 +0000 (GMT) References: <87mumxf6xn.fsf@jidanni.org> <49916778-4758-d040-5fcc-6e277a2dc183@redhat.com> <5b729a22-c3fa-b2b8-f204-ef27ed3a7292@gmail.com> <17f89f02-d446-d964-ffd4-2aae65b411a9@gmail.com> <2d93c9af-d335-21b4-77c2-071532e32c66@cs.ucla.edu> <5b099892-8773-2794-b8f3-437c79a65a5f@gmail.com> <73fbf04f-c237-6a5a-584d-8152cc079f09@cs.ucla.edu> <514735cd-d8de-7f5d-f588-3c15856f1cdc@draigBrady.com> <683b367c-2b3b-1869-af8c-40d5a77370c3@gmail.com> From: =?UTF-8?Q?P=C3=A1draig?= Brady Message-ID: <981a0505-1241-6231-0abe-b851b08d95dc@draigBrady.com> Date: Sat, 23 Feb 2019 22:13:41 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 In-Reply-To: <683b367c-2b3b-1869-af8c-40d5a77370c3@gmail.com> Content-Type: multipart/mixed; boundary="------------8DB4CF49BB01010C16C86313" X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) This is a multi-part message in MIME format. --------------8DB4CF49BB01010C16C86313 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit On 18/02/19 01:46, Assaf Gordon wrote: > Hello, > > Thanks for all comments (on and off list). > Attached an updated patch with documentation. > > The supported options are: > > --default-signal[=SIG] reset signal SIG to its default signal handler. > without SIG, all known signals are included. > multiple signals can be comma-separated. > --ignore-signal[=SIG] set signal SIG to be IGNORED. > without SIG, all known signals are included. > multiple signals can be comma-separated. > -p same as --default-signal=PIPE > > (lower-case "-p" as to not conflict with BSD, but of course can be > changed to another letter). > > The new 'env-signal-handler.sh' test passes on GNU/linux, non-gnu/linux > (alpine), and Free/Open/Net BSD. > > Comments very welcomed, Attached is a patch to be squashed in to: Process the same signals as kill -l Output whether action failed or not Don't run sigaction(..set..) if get failed I'm not that enthusiastic about the -p since it treats PIPE specially here, and it's not special from env's point of view. cheers, Pádraig --------------8DB4CF49BB01010C16C86313 Content-Type: text/x-patch; name="env-default-fixes.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="env-default-fixes.patch" >From 9d873110e29a6f6fb5c4932164e8ce5ad6ad0668 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A1draig=20Brady?= Date: Sat, 23 Feb 2019 22:11:08 -0800 Subject: [PATCH] env: --default fixes Process the same signals as kill -l Output whether action failed or not Don't run sigaction(..set..) if get failed --- src/env.c | 48 +++++++++++++++++++++++++++--------------------- 1 file changed, 27 insertions(+), 21 deletions(-) diff --git a/src/env.c b/src/env.c index 6c20ac4..a601538 100644 --- a/src/env.c +++ b/src/env.c @@ -572,13 +572,13 @@ parse_signal_params (const char* optarg, bool set_default) char *opt_sig; char *optarg_writable; - if (!optarg) + if (! optarg) { /* without an argument, reset all signals. Some signals cannot be set to ignore or default (e.g., SIGKILL, SIGSTOP on most OSes, and SIGCONT on AIX.) - so ignore errors. */ for (int i = 0 ; i < SIGNUM_BOUND; ++i) - if (sig2str (i, signame) == 0) + if (sig2str (i + 1, signame) == 0) signals[i] = set_default ? DEFAULT_NOERR : IGNORE_NOERR; return; } @@ -603,38 +603,44 @@ parse_signal_params (const char* optarg, bool set_default) static void reset_signal_handlers (void) { - for (int i=0; i Original-Sender: "Debbugs-submit" Resent-CC: bug-coreutils@gnu.org Resent-Date: Sun, 24 Feb 2019 18:34:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 34488 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: To: Assaf Gordon Cc: Eric Blake , Bernhard Voelker , =?UTF-8?Q?P=C3=A1draig?= Brady , 34488@debbugs.gnu.org, =?UTF-8?Q?=E7=A9=8D=E4=B8=B9=E5=B0=BC?= Dan Jacobson Received: via spool by 34488-submit@debbugs.gnu.org id=B34488.155103323825138 (code B ref 34488); Sun, 24 Feb 2019 18:34:02 +0000 Received: (at 34488) by debbugs.gnu.org; 24 Feb 2019 18:33:58 +0000 Received: from localhost ([127.0.0.1]:50467 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gxyb7-0006XO-MO for submit@debbugs.gnu.org; Sun, 24 Feb 2019 13:33:57 -0500 Received: from zimbra.cs.ucla.edu ([131.179.128.68]:44130) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gxyb5-0006X3-10 for 34488@debbugs.gnu.org; Sun, 24 Feb 2019 13:33:55 -0500 Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id B11C616145A; Sun, 24 Feb 2019 10:33:48 -0800 (PST) Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id OQGjoyQuB7Mq; Sun, 24 Feb 2019 10:33:47 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id BAA9B161459; Sun, 24 Feb 2019 10:33:47 -0800 (PST) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id CQhRM5cISk0U; Sun, 24 Feb 2019 10:33:47 -0800 (PST) Received: from [192.168.1.9] (cpe-23-242-74-103.socal.res.rr.com [23.242.74.103]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id 869BE161460; Sun, 24 Feb 2019 10:33:47 -0800 (PST) References: <87mumxf6xn.fsf@jidanni.org> <49916778-4758-d040-5fcc-6e277a2dc183@redhat.com> <5b729a22-c3fa-b2b8-f204-ef27ed3a7292@gmail.com> <17f89f02-d446-d964-ffd4-2aae65b411a9@gmail.com> <2d93c9af-d335-21b4-77c2-071532e32c66@cs.ucla.edu> <5b099892-8773-2794-b8f3-437c79a65a5f@gmail.com> <73fbf04f-c237-6a5a-584d-8152cc079f09@cs.ucla.edu> <514735cd-d8de-7f5d-f588-3c15856f1cdc@draigBrady.com> <683b367c-2b3b-1869-af8c-40d5a77370c3@gmail.com> From: Paul Eggert Organization: UCLA Computer Science Department Message-ID: <97dbf933-4bf9-0350-21c4-c4fc87ea788a@cs.ucla.edu> Date: Sun, 24 Feb 2019 10:33:47 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.4.0 MIME-Version: 1.0 In-Reply-To: <683b367c-2b3b-1869-af8c-40d5a77370c3@gmail.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: quoted-printable X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Thanks for doing all that. Although P=C3=A1draig is not enthusiastic abou= t a shortcut=20 like -p, I'm a bit warmer to it, as it's an important special case to fix= a wart=20 in POSIX. No big deal either way. The documentation should mention that SIGCHLD is special, in that=20 --ignore-signal=3DCHLD might have no effect (POSIX says it's unspecified)= . The documentation should say what happens if mutually-contradictory optio= ns are=20 specified, e.g., '--default-signal=3DINT --ignore-signal=3DINT'. Presumab= ly they are=20 processed left-to-right, as is traditional for 'env' with contradictory o= perands. There should be options --block-signal[=3DSIG], --unblock-signal[=3DSIG],= and=20 --setmask-signal[=3DSIG] that affect the signal mask, which is also inher= ited by=20 the child. These can be implemented via pthread_sigmask. The documentation should echo this suggestion in=20 : "m= any=20 existing applications wrongly assume that they start with certain signals= set to=20 the default action and/or unblocked.... Therefore, it is best not to bloc= k or=20 ignore signals across execs without explicit reason to do so, and especia= lly not=20 to block signals across execs of arbitrary (not closely cooperating) prog= rams." From unknown Sun Jun 15 01:09:57 2025 X-Loop: help-debbugs@gnu.org Subject: bug#34488: Add sort --limit, or document workarounds for sort|head error messages In-Reply-To: <87mumxf6xn.fsf@jidanni.org> Resent-From: =?UTF-8?Q?=E7=A9=8D=E4=B8=B9=E5=B0=BC?= Dan Jacobson Original-Sender: "Debbugs-submit" Resent-CC: bug-coreutils@gnu.org Resent-Date: Sun, 24 Feb 2019 18:41:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 34488 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: To: Paul Eggert Cc: Eric Blake , Assaf Gordon , =?UTF-8?Q?P=C3=A1draig?= Brady , Bernhard Voelker , 34488@debbugs.gnu.org Received: via spool by 34488-submit@debbugs.gnu.org id=B34488.155103365626022 (code B ref 34488); Sun, 24 Feb 2019 18:41:03 +0000 Received: (at 34488) by debbugs.gnu.org; 24 Feb 2019 18:40:56 +0000 Received: from localhost ([127.0.0.1]:50478 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gxyhs-0006ld-2O for submit@debbugs.gnu.org; Sun, 24 Feb 2019 13:40:56 -0500 Received: from firebrick.maple.relay.mailchannels.net ([23.83.214.59]:35078) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gxyho-0006lG-CY for 34488@debbugs.gnu.org; Sun, 24 Feb 2019 13:40:53 -0500 X-Sender-Id: dreamhost|x-authsender|jidanni@jidanni.org Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id 5B4BF123D7E; Sun, 24 Feb 2019 18:40:49 +0000 (UTC) Received: from pdx1-sub0-mail-a29.g.dreamhost.com (unknown [100.96.11.5]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id 0A2891245C8; Sun, 24 Feb 2019 18:40:49 +0000 (UTC) X-Sender-Id: dreamhost|x-authsender|jidanni@jidanni.org Received: from pdx1-sub0-mail-a29.g.dreamhost.com (pop.dreamhost.com [64.90.62.162]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384) by 0.0.0.0:2500 (trex/5.16.3); Sun, 24 Feb 2019 18:40:49 +0000 X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|jidanni@jidanni.org X-MailChannels-Auth-Id: dreamhost X-Dime-Imminent: 4ea649e93d048a1d_1551033649180_2020383276 X-MC-Loop-Signature: 1551033649179:3232264399 X-MC-Ingress-Time: 1551033649179 Received: from pdx1-sub0-mail-a29.g.dreamhost.com (localhost [127.0.0.1]) by pdx1-sub0-mail-a29.g.dreamhost.com (Postfix) with ESMTP id BA22280A22; Sun, 24 Feb 2019 10:40:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=jidanni.org; h=from:to:cc :subject:references:date:message-id:mime-version:content-type; s=jidanni.org; bh=w2WkgNF2hycK/f4ximoAgq4pAz0=; b=iiQFz3U9QzQGL kd5zjC5oLrYk1xynSXCvcHLvN2cWeLAXwSQwm4Cl2jAzhsc+uwF8jzjUcHPNFF6A pnDshJXYy/8M17/f+8lLomm8rTudc0Zq/KdKO+u7cz4TFwwqNOra6B3LhZGtRrdW WKKTba+w6V/nLaBcTbTYPPpMuq5mH8= Received: from jidanni.org (220-140-8-35.dynamic-ip.hinet.net [220.140.8.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: jidanni@jidanni.org) by pdx1-sub0-mail-a29.g.dreamhost.com (Postfix) with ESMTPSA id 636DE80A20; Sun, 24 Feb 2019 10:40:46 -0800 (PST) X-DH-BACKEND: pdx1-sub0-mail-a29 From: =?UTF-8?Q?=E7=A9=8D=E4=B8=B9=E5=B0=BC?= Dan Jacobson References: <87mumxf6xn.fsf@jidanni.org> <49916778-4758-d040-5fcc-6e277a2dc183@redhat.com> <5b729a22-c3fa-b2b8-f204-ef27ed3a7292@gmail.com> <17f89f02-d446-d964-ffd4-2aae65b411a9@gmail.com> <2d93c9af-d335-21b4-77c2-071532e32c66@cs.ucla.edu> <5b099892-8773-2794-b8f3-437c79a65a5f@gmail.com> <73fbf04f-c237-6a5a-584d-8152cc079f09@cs.ucla.edu> <514735cd-d8de-7f5d-f588-3c15856f1cdc@draigBrady.com> <683b367c-2b3b-1869-af8c-40d5a77370c3@gmail.com> <97dbf933-4bf9-0350-21c4-c4fc87ea788a@cs.ucla.edu> Date: Mon, 25 Feb 2019 02:40:41 +0800 Message-ID: <87k1hpf2s6.fsf@jidanni.org> MIME-Version: 1.0 Content-Type: text/plain X-VR-OUT-STATUS: OK X-VR-OUT-SCORE: -100 X-VR-OUT-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedutddrudeggdduudeiucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuggftfghnshhusghstghrihgsvgdpffftgfetoffjqffuvfenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephffvufhffffkgggtsehttdertddttdejnecuhfhrohhmpejnnjjnucffrghnucflrggtohgsshhonhcuoehjihgurghnnhhisehjihgurghnnhhirdhorhhgqeenucfkphepvddvtddrudegtddrkedrfeehnecurfgrrhgrmhepmhhouggvpehsmhhtphdphhgvlhhopehjihgurghnnhhirdhorhhgpdhinhgvthepvddvtddrudegtddrkedrfeehpdhrvghtuhhrnhdqphgrthhhpeeprehuthhfqdekreeureehiehmpfehnfhiheehsgevkeerpecuffgrnhculfgrtghosghsohhnuceojhhiuggrnhhnihesjhhiuggrnhhnihdrohhrgheqpdhmrghilhhfrhhomhepjhhiuggrnhhnihesjhhiuggrnhhnihdrohhrghdpnhhrtghpthhtohepfeeggeekkeesuggvsggsuhhgshdrghhnuhdrohhrghenucevlhhushhtvghrufhiiigvpedt X-Spam-Score: 0.1 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.9 (/) Thanks for working on this guys, hopefully users will one day no longer be faced with (yes, seemingly) random errors. $ ls -l | sed 2!d drwxr-xr-x 14 jidanni jidanni 4096 2016-12-24 AndroidMisc $ ls -l | sed 2q total 157780 drwxr-xr-x 14 jidanni jidanni 4096 2016-12-24 AndroidMisc ls: write error: Broken pipe From unknown Sun Jun 15 01:09:57 2025 X-Loop: help-debbugs@gnu.org Subject: bug#34488: Add sort --limit, or document workarounds for sort|head error messages Resent-From: Eric Blake Original-Sender: "Debbugs-submit" Resent-CC: bug-coreutils@gnu.org Resent-Date: Mon, 25 Feb 2019 14:02:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 34488 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: To: =?UTF-8?Q?P=C3=A1draig?= Brady , =?UTF-8?Q?=E7=A9=8D=E4=B8=B9=E5=B0=BC?= Dan Jacobson , 34488@debbugs.gnu.org Received: via spool by 34488-submit@debbugs.gnu.org id=B34488.155110331410965 (code B ref 34488); Mon, 25 Feb 2019 14:02:02 +0000 Received: (at 34488) by debbugs.gnu.org; 25 Feb 2019 14:01:54 +0000 Received: from localhost ([127.0.0.1]:50958 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gyGpO-0002qm-0P for submit@debbugs.gnu.org; Mon, 25 Feb 2019 09:01:54 -0500 Received: from mx1.redhat.com ([209.132.183.28]:51792) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gyGpM-0002qZ-L7 for 34488@debbugs.gnu.org; Mon, 25 Feb 2019 09:01:53 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id AE47380F84; Mon, 25 Feb 2019 14:01:46 +0000 (UTC) Received: from [10.3.116.222] (ovpn-116-222.phx2.redhat.com [10.3.116.222]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 518B8600C8; Mon, 25 Feb 2019 14:01:46 +0000 (UTC) References: <87mumxf6xn.fsf@jidanni.org> <49916778-4758-d040-5fcc-6e277a2dc183@redhat.com> <4c48e648-d890-ab12-a364-d5b88b0f2903@draigBrady.com> From: Eric Blake Organization: Red Hat, Inc. Message-ID: Date: Mon, 25 Feb 2019 08:01:44 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.5.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Mon, 25 Feb 2019 14:01:46 +0000 (UTC) X-Spam-Score: -5.0 (-----) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -6.0 (------) On 2/23/19 11:32 PM, Pádraig Brady wrote: >>>> You HAVE to use some other intermediate program if you want to override >>>> an inherited ignored SIGPIPE in sh into an inherited default-behavior >>>> SIGPIPE in sort. >>> >>> Should we also propose to POSIX to allow trap to specify default? >> >> That's what "trap - PIPE" is already supposed to do, except that POSIX >> has the odd requirement that a signal that was inherited ignored cannot >> be reset to default. >> >>> Maybe `trap 0 PIPE` or similar? >> >> Alas, bash has already defined that to mean the same as 'trap - EXIT PIPE'. > > Fair enough, but do we agree that it would be good > to have functionality in the shell with some similar syntax > that resets the handler to system default? Worth asking on the bash list to see if Chet has any interest in such an extension (POSIX is reluctant to specify something that doesn't have existing implementation practice). -- Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3226 Virtualization: qemu.org | libvirt.org From unknown Sun Jun 15 01:09:57 2025 X-Loop: help-debbugs@gnu.org Subject: bug#34488: Add sort --limit, or document workarounds for sort|head error messages Resent-From: Assaf Gordon Original-Sender: "Debbugs-submit" Resent-CC: bug-coreutils@gnu.org Resent-Date: Tue, 26 Feb 2019 01:16:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 34488 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: To: Paul Eggert Cc: Eric Blake , Bernhard Voelker , =?UTF-8?Q?P=C3=A1draig?= Brady , 34488@debbugs.gnu.org, =?UTF-8?Q?=E7=A9=8D=E4=B8=B9=E5=B0=BC?= Dan Jacobson Received: via spool by 34488-submit@debbugs.gnu.org id=B34488.155114372532570 (code B ref 34488); Tue, 26 Feb 2019 01:16:02 +0000 Received: (at 34488) by debbugs.gnu.org; 26 Feb 2019 01:15:25 +0000 Received: from localhost ([127.0.0.1]:51986 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gyRL1-0008T8-QE for submit@debbugs.gnu.org; Mon, 25 Feb 2019 20:15:24 -0500 Received: from mail-pf1-f181.google.com ([209.85.210.181]:43471) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gyRKy-0008Sp-Uv for 34488@debbugs.gnu.org; Mon, 25 Feb 2019 20:15:14 -0500 Received: by mail-pf1-f181.google.com with SMTP id q17so5341752pfh.10 for <34488@debbugs.gnu.org>; Mon, 25 Feb 2019 17:15:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language; bh=XRbPO3sl99o/jWdIa0DXlwLilRsvgzKEe44cUbvQFNA=; b=CgZ5OehSzGr+Ib6yev+lxoUHpR2FtBylruAmV4jikGEbdY0p15Fmz2PcZemQpVL3bj dJExgyjGhOm0GkgZNJsVl+0aDXyLMatWmB74kd3k4LY8ckiFTq4GNJNJ5aEYX9sy3gBB b3pZHAeS8FPqzucQ6z53PU4/3epiylc6M/lrhKBvHSEdQVMjGXK4iiw7E/GfwlnkSDXq zArX6AT5Ti6GdTypMaeama94/baARuYH6XfxSrG2HJ/gDcY7y3FtzPJDsxppwo2j2n4E M//iaQtYUzPF5LMz5GhuLFJzi1GhjHw+EgpFlV1LEmDaCLys5p5Ct9GnDYXcze+euWix PLqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language; bh=XRbPO3sl99o/jWdIa0DXlwLilRsvgzKEe44cUbvQFNA=; b=AL1MF1gyWILM4oqRHd+ieu4iVlsJpXTwS91p802D2Shm3CcXbNhnSOL64eFibBh5sm 9C3GHMgQ8QPCNZSuw3e2YIdC8B16NC02MXfJZsvQpljCLKB8xQ7Op0s6z55T3jDUsDIq 0tXC02wUYoOz1kOx6cZUqcLifHC9UDfRl1jvwgbdjqD88DkrqocmrIbjEVxzKxu+XOvW 2lek9htyhoc2Mye0FJCM5ZhwsdzqcEEHAk53mFpoOL5QicZ9VE8otagl11OmnV/9OAuL UPQmzHokkWfVopJ3ZwqlL2xYXZ0Yzo90UU8KToxKj6NtXItNHZzvoWS9G/Bg8UqzkeeE 4tSA== X-Gm-Message-State: AHQUAuZbw0BH6EoiObx0UtZ9G00IUioFfMKjK6Qa9OCsfgHYrSRM8/gI VV5ZiBtXYjjTCk6ceV6al/y1QGKd X-Google-Smtp-Source: AHgI3IYw5qej4t8kGOJTlLwApZTSM08Fx69HavIB/B8xiourc6zJNwnBYnzADMencrrEjXpf//bvIA== X-Received: by 2002:a62:b608:: with SMTP id j8mr23806087pff.183.1551143706263; Mon, 25 Feb 2019 17:15:06 -0800 (PST) Received: from tomato.housegordon.com (moose.housegordon.com. [184.68.105.38]) by smtp.googlemail.com with ESMTPSA id 64sm16503454pff.101.2019.02.25.17.15.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 25 Feb 2019 17:15:04 -0800 (PST) References: <87mumxf6xn.fsf@jidanni.org> <49916778-4758-d040-5fcc-6e277a2dc183@redhat.com> <5b729a22-c3fa-b2b8-f204-ef27ed3a7292@gmail.com> <17f89f02-d446-d964-ffd4-2aae65b411a9@gmail.com> <2d93c9af-d335-21b4-77c2-071532e32c66@cs.ucla.edu> <5b099892-8773-2794-b8f3-437c79a65a5f@gmail.com> <73fbf04f-c237-6a5a-584d-8152cc079f09@cs.ucla.edu> <514735cd-d8de-7f5d-f588-3c15856f1cdc@draigBrady.com> <683b367c-2b3b-1869-af8c-40d5a77370c3@gmail.com> <97dbf933-4bf9-0350-21c4-c4fc87ea788a@cs.ucla.edu> From: Assaf Gordon Message-ID: <20151538-6173-bb98-f719-325a8b1724d6@gmail.com> Date: Mon, 25 Feb 2019 18:15:03 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.4.0 MIME-Version: 1.0 In-Reply-To: <97dbf933-4bf9-0350-21c4-c4fc87ea788a@cs.ucla.edu> Content-Type: multipart/mixed; boundary="------------C3D7A90883F10EA2249DFCA6" Content-Language: en-US X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) This is a multi-part message in MIME format. --------------C3D7A90883F10EA2249DFCA6 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Hello, Thanks for all comments. On 2019-02-24 11:33 a.m., Paul Eggert wrote: > Thanks for doing all that. Although Pádraig is not enthusiastic about a > shortcut like -p, I'm a bit warmer to it, as it's an important special > case to fix a wart in POSIX. No big deal either way. For now I kept "-p", can be removed later of course. The first patch includes Pádraig's recent suggestions (slightly modified). > The documentation should mention that SIGCHLD is special [...] > The documentation should say what happens if mutually-contradictory > options are specified, [...] > The documentation should echo this suggestion in > : I've added those, and I welcome all improvements suggestion to grammar/phrasing/etc. > There should be options --block-signal[=SIG], --unblock-signal[=SIG], > and --setmask-signal[=SIG] that affect the signal mask, which is also > inherited by the child. These can be implemented via pthread_sigmask. The second patch adds these new options (separated to ease review). As for documentation - I'm not sure what to add beyond the basic option description. When should these be used? A third small patch adds "env ---list-signal-actions" and "env --list-blocked-signals" - to ease diagnostics. Might be worth adding for completeness (e.g., for users who need to somehow know if SIGPIPE is being ignored by the shell or not): $ ( trap '' PIPE && src/env --list-signal-actions ) PIPE (13): ignore Comments very welcomed, - assaf --------------C3D7A90883F10EA2249DFCA6 Content-Type: text/x-patch; name="0001-env-new-options-p-default-signal-SIG-ignore-signal-S.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0001-env-new-options-p-default-signal-SIG-ignore-signal-S.pa"; filename*1="tch" >From 02cba657e2f63c05f859daf18a7d1032fdc32c6f Mon Sep 17 00:00:00 2001 From: Assaf Gordon Date: Fri, 15 Feb 2019 12:31:48 -0700 Subject: [PATCH 1/3] env: new options -p/--default-signal=SIG/--ignore-signal=SIG New options to set signal handlers to default (SIG_DFL) or ignore (SIG_IGN) This is useful to overcome POSIX limitation that shell must not override inherited signal state, e.g. the second 'trap' here is a no-op: trap '' PIPE && sh -c 'trap - PIPE ; seq inf | head -n1' Instead use: trap '' PIPE && sh -c 'env -p seq inf | head -n1' Similarly, the following will prevent CTRL-C from terminating the program: env --ignore-signal=INT seq inf > /dev/null See https://bugs.gnu.org/34488#8 . * NEWS: Mention new options. * doc/coreutils.texi (env invocation): Document new options. * man/env.x: Add example of --default-signal=SIG usage. * src/env.c (signals): New global variable. (shortopts,longopts): Add new options. (usage): Print new options. (parse_signal_params): Parse comma-separated list of signals, store in signals variable. (reset_signal_handlers): Set each signal to SIG_DFL/SIG_IGN. (main): Process new options. * src/local.mk (src_env_SOURCES): Add operand2sig.c. * tests/misc/env-signal-handler.sh: New test. * tests/local.mk (all_tests): Add new test. --- NEWS | 3 + doc/coreutils.texi | 58 ++++++++++++++++ man/env.x | 69 ++++++++++++++++++ src/env.c | 138 +++++++++++++++++++++++++++++++++++- src/local.mk | 1 + tests/local.mk | 1 + tests/misc/env-signal-handler.sh | 146 +++++++++++++++++++++++++++++++++++++++ 7 files changed, 415 insertions(+), 1 deletion(-) create mode 100755 tests/misc/env-signal-handler.sh diff --git a/NEWS b/NEWS index e73cb52b8..ddbbaf138 100644 --- a/NEWS +++ b/NEWS @@ -81,6 +81,9 @@ GNU coreutils NEWS -*- outline -*- test now supports the '-N FILE' unary operator (like e.g. bash) to check whether FILE exists and has been modified since it was last read. + env now supports '--default-singal[=SIG]' and '--ignore-signal[=SIG]' + options to set signal handlers before executing a program. + ** New commands basenc is added to complement existing base64,base32 commands, diff --git a/doc/coreutils.texi b/doc/coreutils.texi index eb1848882..c2c202b28 100644 --- a/doc/coreutils.texi +++ b/doc/coreutils.texi @@ -17246,6 +17246,64 @@ chroot /chroot env --chdir=/srv true env --chdir=/build FOO=bar timeout 5 true @end example +@item --default-signal[=@var{sig}] +Reset signal @var{sig} to its default signal handler. Without @var{sig} all +known signals are reset to their defaults. Multiple signals can be +comma-separated. The following command runs @command{seq} with SIGINT and +SIGPIPE set to their default (which is to terminate the program): + +@example +env --default-signal=PIPE,INT seq 1000 | head -n1 +@end example + +In the following example: + +@example +trap '' PIPE && sh -c 'trap - PIPE ; seq inf | head -n1' +@end example + +The first trap command sets SIGPIPE to ignore. The second trap command +ostensibly sets it back to its default, but POSIX mandates that the shell +must not change inherited state of the signal - so it is a no-op. + +Using @option{--default-signal=PIPE} (or its shortcut @option{-p}) can be +used to force the signal to its default behavior: + +@example +trap '' PIPE && sh -c "env -p seq inf | head -n1' +@end example + + +@item --ignore-signal[=@var{sig}] +Ignore signal @var{sig} when running a program. Without @var{sig} all +known signals are set to ignore. Multiple signals can be +comma-separated. The following command runs @command{seq} with SIGINT set +to be ignored - pressing @kbd{Ctrl-C} will not terminate it: + +@example +env --ignore-signal=INT seq inf > /dev/null +@end example + +@samp{SIGCHLD} is special, in that @option{--ignore-signal=CHLD} might have +no effect (POSIX says it's unspecified). + +Most operating systems do not allow ignoring @samp{SIGKILL}, @samp{SIGSTOP} +(and possibly other signals). Attempting to ignore these signals will fail. + +Multiple (and contradictory) @option{--default-signal=SIG} and +@option{--ignore-signal=SIG} options are processed left-to-right, +with the latter taking precedence. In the follwing example, @samp{SIGPIPE} is +set to default while @samp{SIGINT} is ignored: + +@example +env --default-signal=INT,PIPE --ignore-signal=INT +@end example + + +@item -p +Equivalent to @option{--default-signal=PIPE} - sets SIGPIPE to its default +behavior (terminate a program upon @samp{SIGPIPE}). + @item -v @itemx --debug @opindex -v diff --git a/man/env.x b/man/env.x index 8eea79655..09c7f0f3a 100644 --- a/man/env.x +++ b/man/env.x @@ -37,3 +37,72 @@ parameter the script will likely fail with: .RE .PP See the full documentation for more details. +.PP +.SS "\-\-default-signal[=SIG]" to 'untrap' a singal +This option allows setting a signal handler to its default +action. This is useful to reset a signal after setting it +to 'ignore' using the shell's trap command. + +In the following example: +.PP +.RS +.nf +trap '' PIPE && sh \-c 'trap \- PIPE ; seq inf | head \-n1' +.fi +.RE +.PP +The first +.B trap +command sets SIGPIPE to ignore. +The second +.B trap +command ostensibly sets it back to its default, but POSIX mandates that the +shell must not change inherited state of the signal - so it is a no-op. +.PP +Using +.B \-\-default-signal=PIPE +(or its shortcut +.B \-p +) +can be used to force the signal to its default behavior: +.PP +.RS +.nf +trap '' PIPE && sh \-c "env \-p seq inf | head \-n1' +.fi +.RE +.PP +.B SIGCHLD +is special in that +.B \-\-ignore\-signal=CHLD +might have no effect (POSIX says it's unspecified). +.PP +Most operating systems do not allow ignoring +.B SIGKILL, SIGSTOP +(and possibly other signals). +Attempting to ignore these signals will fail. +.PP +Multiple (and contradictory) +.B \-\-default\-signal=SIG +and +.B \-\-ignore\-signal=SIG +options are processed left-to-right, with the latter taking precedence. +In the follwing example, SIGPIPE is set to default while SIGINT is ignored: +.RS +.nf +env \-\-default\-signal=INT,PIPE \-\-ignore\-signal=INT +.fi +.RE + +[NOTES] +POSIX's exec(2) pages says: +.RS +"many existing applications wrongly assume that they start with certain +signals set to the default action and/or unblocked.... Therefore, it is best +not to block or ignore signals across execs without explicit reason to do so, +and especially not to block signals across execs of arbitrary (not closely +cooperating) programs." +.RE + +[SEE ALSO] +sigaction(2), signal(7) diff --git a/src/env.c b/src/env.c index 3a1a3869e..bd9b68560 100644 --- a/src/env.c +++ b/src/env.c @@ -21,12 +21,15 @@ #include #include #include +#include #include #include "system.h" #include "die.h" #include "error.h" +#include "operand2sig.h" #include "quote.h" +#include "sig2str.h" /* The official name of this program (e.g., no 'g' prefix). */ #define PROGRAM_NAME "env" @@ -48,7 +51,27 @@ static bool dev_debug; static char *varname; static size_t vnlen; -static char const shortopts[] = "+C:iS:u:v0 \t"; +/* Possible actions on each signal. */ +enum SIGNAL_MODE { + UNCHANGED = 0, + DEFAULT, /* Set to default handler (SIG_DFL). */ + DEFAULT_NOERR, /* ditto, but ignore sigaction(2) errors. */ + IGNORE, /* Set to ignore (SIG_IGN). */ + IGNORE_NOERR /* ditto, but ignore sigaction(2) errors. */ +}; +static enum SIGNAL_MODE signals[SIGNUM_BOUND]; + + + +static char const shortopts[] = "+C:ipS:u:v0 \t"; + +/* For long options that have no equivalent short option, use a + non-character as a pseudo short option, starting with CHAR_MAX + 1. */ +enum +{ + DEFAULT_SIGNAL_OPTION = CHAR_MAX + 1, + IGNORE_SIGNAL_OPTION +}; static struct option const longopts[] = { @@ -56,6 +79,8 @@ static struct option const longopts[] = {"null", no_argument, NULL, '0'}, {"unset", required_argument, NULL, 'u'}, {"chdir", required_argument, NULL, 'C'}, + {"default-signal", optional_argument, NULL, DEFAULT_SIGNAL_OPTION}, + {"ignore-signal", optional_argument, NULL, IGNORE_SIGNAL_OPTION}, {"debug", no_argument, NULL, 'v'}, {"split-string", required_argument, NULL, 'S'}, {GETOPT_HELP_OPTION_DECL}, @@ -88,8 +113,19 @@ Set each NAME to VALUE in the environment and run COMMAND.\n\ -C, --chdir=DIR change working directory to DIR\n\ "), stdout); fputs (_("\ + --default-signal[=SIG] set signal SIG to its default action.\n\ +"), stdout); + fputs (_("\ + --ignore-signal[=SIG] set signal SIG to be ignored.\n\ +"), stdout); + fputs (_("\ -S, --split-string=S process and split S into separate arguments;\n\ used to pass multiple arguments on shebang lines\n\ +"), stdout); + fputs (_("\ + -p same as --default-signal=PIPE\n\ +"), stdout); + fputs (_("\ -v, --debug print verbose information for each processing step\n\ "), stdout); fputs (HELP_OPTION_DESCRIPTION, stdout); @@ -98,6 +134,13 @@ Set each NAME to VALUE in the environment and run COMMAND.\n\ \n\ A mere - implies -i. If no COMMAND, print the resulting environment.\n\ "), stdout); + fputs (_("\ +\n\ +SIG may be a signal name like 'PIPE', or a signal number like '13'.\n\ +Without SIG, all known signals are included. Multiple signals can be\n\ +comma-separated.\n\ +\n\ +"), stdout); emit_ancillary_info (PROGRAM_NAME); } exit (status); @@ -525,6 +568,87 @@ parse_split_string (const char* str, int /*out*/ *orig_optind, *orig_optind = 0; /* tell getopt to restart from first argument */ } +static void +parse_signal_action_params (const char* optarg, bool set_default) +{ + char signame[SIG2STR_MAX]; + char *opt_sig; + char *optarg_writable; + + if (! optarg) + { + /* without an argument, reset all signals. + Some signals cannot be set to ignore or default (e.g., SIGKILL, + SIGSTOP on most OSes, and SIGCONT on AIX.) - so ignore errors. */ + for (int i = 1 ; i < SIGNUM_BOUND; ++i) + if (sig2str (i, signame) == 0) + signals[i] = set_default ? DEFAULT_NOERR : IGNORE_NOERR; + return; + } + + optarg_writable = xstrdup (optarg); + + opt_sig = strtok (optarg_writable, ","); + while (opt_sig) + { + int signum = operand2sig (opt_sig, signame); + /* operand2sig accepts signal 0 (EXIT) - but we reject it. */ + if (signum == 0) + error (0, 0, _("%s: invalid signal"), quote (opt_sig)); + if (signum <= 0) + usage (exit_failure); + + signals[signum] = set_default ? DEFAULT : IGNORE; + + opt_sig = strtok (NULL, ","); + } + + free (optarg_writable); +} + +static void +reset_signal_handlers (void) +{ + for (int i = 1; i < SIGNUM_BOUND; i++) + { + struct sigaction act; + + if (signals[i] == UNCHANGED) + continue; + + bool ignore_errors = (signals[i] == DEFAULT_NOERR + || signals[i] == IGNORE_NOERR); + + bool set_to_default = (signals[i] == DEFAULT + || signals[i] == DEFAULT_NOERR); + + int sig_err = sigaction (i, NULL, &act); + + if (sig_err && !ignore_errors) + die (EXIT_CANCELED, errno, + _("failed to get signal action for signal %d"), i); + + if (! sig_err) + { + act.sa_handler = set_to_default ? SIG_DFL : SIG_IGN; + + if ((sig_err = sigaction (i, &act, NULL)) && !ignore_errors) + die (EXIT_CANCELED, errno, + _("failed to set signal action for signal %d"), i); + } + + if (dev_debug) + { + char signame[SIG2STR_MAX]; + sig2str (i, signame); + devmsg ("Reset signal %s (%d) to %s%s\n", + signame, i, + set_to_default ? "DEFAULT" : "IGNORE", + sig_err ? " (failure ignored)" : ""); + } + } +} + int main (int argc, char **argv) { @@ -558,6 +682,16 @@ main (int argc, char **argv) case '0': opt_nul_terminate_output = true; break; + case 'p': + /* alias to --default-signal=PIPE */ + signals[SIGPIPE] = DEFAULT; + break; + case DEFAULT_SIGNAL_OPTION: + parse_signal_action_params (optarg, true); + break; + case IGNORE_SIGNAL_OPTION: + parse_signal_action_params (optarg, false); + break; case 'C': newdir = optarg; break; @@ -633,6 +767,8 @@ main (int argc, char **argv) return EXIT_SUCCESS; } + reset_signal_handlers (); + if (newdir) { devmsg ("chdir: %s\n", quoteaf (newdir)); diff --git a/src/local.mk b/src/local.mk index ba219d530..a69d40521 100644 --- a/src/local.mk +++ b/src/local.mk @@ -356,6 +356,7 @@ src_coreutils_SOURCES = src/coreutils.c src_cp_SOURCES = src/cp.c $(copy_sources) $(selinux_sources) src_dir_SOURCES = src/ls.c src/ls-dir.c +src_env_SOURCES = src/env.c src/operand2sig.c src_vdir_SOURCES = src/ls.c src/ls-vdir.c src_id_SOURCES = src/id.c src/group-list.c src_groups_SOURCES = src/groups.c src/group-list.c diff --git a/tests/local.mk b/tests/local.mk index bcb61edc7..d67e4e80c 100644 --- a/tests/local.mk +++ b/tests/local.mk @@ -240,6 +240,7 @@ all_tests = \ tests/fmt/goal-option.sh \ tests/misc/echo.sh \ tests/misc/env.sh \ + tests/misc/env-signal-handler.sh \ tests/misc/ptx.pl \ tests/misc/test.pl \ tests/misc/seq.pl \ diff --git a/tests/misc/env-signal-handler.sh b/tests/misc/env-signal-handler.sh new file mode 100755 index 000000000..b5315499e --- /dev/null +++ b/tests/misc/env-signal-handler.sh @@ -0,0 +1,146 @@ +#!/bin/sh +# Test env --default-signal=PIPE feature. + +# Copyright (C) 2019 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src +print_ver_ seq +print_ver_ timeout +print_ver_ test +trap_sigpipe_or_skip_ + +# Paraphrasing http://bugs.gnu.org/34488#8: +# POSIX requires that sh started with an inherited ignored SIGPIPE must +# silently ignore all attempts from within the shell to restore SIGPIPE +# handling to child processes of the shell: +# +# $ (trap '' PIPE; bash -c 'trap - PIPE; seq inf | head -n1') +# 1 +# seq: write error: Broken pipe +# +# With 'env --default-signal=PIPE', the signal handler can be reset to its +# default. + +# Baseline Test - default signal handler +# -------------------------------------- +# Ensure this results in a "broken pipe" error (the first 'trap' +# sets SIGPIPE to ignore, and the second 'trap' becomes a no-op instead +# of resetting SIGPIPE to its default). Upon a SIGPIPE 'seq' will not be +# terminated, instead its write(2) call will return an error. +(trap '' PIPE; sh -c 'trap - PIPE; seq 999999 2>err1t | head -n1 > out1') + +# The exact broken pipe message depends on the operating system, just ensure +# there was a 'write error' message in stderr: +sed 's/^\(seq: write error:\) .*/\1/' err1t > err1 || framework_failure_ + +printf "1\n" > exp-out || framework_failure_ +printf "seq: write error:\n" > exp-err1 || framework_failure_ + +compare exp-out out1 || framework_failure_ +compare exp-err1 err1 || framework_failure_ + + +# env test - default signal handler +# --------------------------------- +# With env resetting the signal handler to its defaults, there should be no +# error message (because the default SIGPIPE action is to terminate the +# 'seq' program): +(trap '' PIPE; + env --default-signal=PIPE \ + sh -c 'trap - PIPE; seq 999999 2>err2 | head -n1 > out2') + +compare exp-out out2 || fail=1 +compare /dev/null err2 || fail=1 + +# env test - default signal handler (2) +# ------------------------------------- +# Repeat the previous test, using "-p" (shortcut for --default-signal=PIPE): +(trap '' PIPE; + env -p \ + sh -c 'trap - PIPE; seq 999999 2>err3 | head -n1 > out3') + +compare exp-out out3 || fail=1 +compare /dev/null err3 || fail=1 + +# env test - default signal handler (3) +# ------------------------------------- +# Repeat the previous test, using --default-signal with no signal names, +# i.e., all signals. +(trap '' PIPE; + env --default-signal \ + sh -c 'trap - PIPE; seq 999999 2>err4 | head -n1 > out4') + +compare exp-out out4 || fail=1 +compare /dev/null err4 || fail=1 + + + + + + +# Baseline test - ignore signal handler +# ------------------------------------- +# Kill 'seq' after 1 second with SIGINT - it should terminate (as SIGINT's +# default action is to terminate a program). +# (The first 'env' is just to ensure timeout is not the shell's built-in.) +env timeout --verbose --kill-after=1 --signal=INT 1 \ + seq inf > /dev/null 2>err5 + +printf "timeout: sending signal INT to command 'seq'\n" > exp-err5 \ + || framework_failure_ + +compare exp-err5 err5 || fail=1 + + +# env test - ignore signal handler +# -------------------------------- +# Use env to silence (ignore) SIGINT - "seq" should continue running +# after timeout sends SIGINT, and be killed after 1 second using SIGKILL. + +cat>exp-err6 < /dev/null 2>err6t + +# check only the first two lines from stderr, which are printed by timeout. +# (operating systems might add more messages, like "killed"). +sed -n '1,2p' err6t > err6 || framework_failure_ + +compare exp-err6 err6 || fail=1 + + +# env test - ignore signal handler (2) +# ------------------------------------ +# Repeat the previous test with "--ignore-signals" and no signal names, +# i.e., all signals. + +env timeout --verbose --kill-after=1 --signal=INT 1 \ + env --ignore-signal \ + seq inf > /dev/null 2>err7t + +# check only the first two lines from stderr, which are printed by timeout. +# (operating systems might add more messages, like "killed"). +sed -n '1,2p' err7t > err7 || framework_failure_ + +compare exp-err6 err7 || fail=1 + + + +Exit $fail -- 2.11.0 --------------C3D7A90883F10EA2249DFCA6 Content-Type: text/x-patch; name="0002-env-add-block-unblock-setmask-signal-SIG-options.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0002-env-add-block-unblock-setmask-signal-SIG-options.patch" >From deb0d5a64eef13bdffe9a84f98fc6a5b18805262 Mon Sep 17 00:00:00 2001 From: Assaf Gordon Date: Mon, 25 Feb 2019 15:37:47 -0700 Subject: [PATCH 2/3] env: add --{block,unblock,setmask}-signal=SIG options Suggested by Paul Eggert in http://bugs.gnu.org/34488#71 . * NEWS: Mention new options. * doc/coreutils.texi (env invocation): Document new options. * src/env.c (block_signals, unblock_signals): New global variables. (longopts, usage): Add new options. (parse_block_signal_params): Parse command-line options. (set_signal_proc_mask): Call sigprocmask to block/unblock signals. (main): Handle new command-line options, call set_signal_proc_mask. * man/env.x (SEE ALSO): Mention sigprocmask. --- NEWS | 3 ++ doc/coreutils.texi | 10 +++++ man/env.x | 2 +- src/env.c | 112 ++++++++++++++++++++++++++++++++++++++++++++++++++++- 4 files changed, 125 insertions(+), 2 deletions(-) diff --git a/NEWS b/NEWS index ddbbaf138..cb8aa107f 100644 --- a/NEWS +++ b/NEWS @@ -84,6 +84,9 @@ GNU coreutils NEWS -*- outline -*- env now supports '--default-singal[=SIG]' and '--ignore-signal[=SIG]' options to set signal handlers before executing a program. + env now supports '--{block,unblock,setmask}-singal[=SIG]' to block/unblock + signal delivery before executing a program. + ** New commands basenc is added to complement existing base64,base32 commands, diff --git a/doc/coreutils.texi b/doc/coreutils.texi index c2c202b28..8f5212a72 100644 --- a/doc/coreutils.texi +++ b/doc/coreutils.texi @@ -17299,6 +17299,16 @@ set to default while @samp{SIGINT} is ignored: env --default-signal=INT,PIPE --ignore-signal=INT @end example +@item --block-signal[=@var{sig}] +Block signal @var{sig} from being delivered. + +@item --unblock-signal[=@var{sig}] +Unblock signal @var{sig}. + +@item --setmask-signal[=@var{sig}] +Set list of blocked signals to @var{sig}. All other signals will be unblocked. + + @item -p Equivalent to @option{--default-signal=PIPE} - sets SIGPIPE to its default diff --git a/man/env.x b/man/env.x index 09c7f0f3a..b787fe3a7 100644 --- a/man/env.x +++ b/man/env.x @@ -105,4 +105,4 @@ cooperating) programs." .RE [SEE ALSO] -sigaction(2), signal(7) +sigaction(2), sigprocmask(2), signal(7) diff --git a/src/env.c b/src/env.c index bd9b68560..4cae7d47f 100644 --- a/src/env.c +++ b/src/env.c @@ -61,6 +61,11 @@ enum SIGNAL_MODE { }; static enum SIGNAL_MODE signals[SIGNUM_BOUND]; +/* Set of signals to block. */ +static sigset_t block_signals; + +/* Set of signals to unblock. */ +static sigset_t unblock_signals; static char const shortopts[] = "+C:ipS:u:v0 \t"; @@ -70,7 +75,10 @@ static char const shortopts[] = "+C:ipS:u:v0 \t"; enum { DEFAULT_SIGNAL_OPTION = CHAR_MAX + 1, - IGNORE_SIGNAL_OPTION + IGNORE_SIGNAL_OPTION, + BLOCK_SIGNAL_OPTION, + UNBLOCK_SIGNAL_OPTION, + SETMASK_SIGNAL_OPTION }; static struct option const longopts[] = @@ -81,6 +89,9 @@ static struct option const longopts[] = {"chdir", required_argument, NULL, 'C'}, {"default-signal", optional_argument, NULL, DEFAULT_SIGNAL_OPTION}, {"ignore-signal", optional_argument, NULL, IGNORE_SIGNAL_OPTION}, + {"block-signal", optional_argument, NULL, BLOCK_SIGNAL_OPTION}, + {"unblock-signal", optional_argument, NULL, UNBLOCK_SIGNAL_OPTION}, + {"setmask-signal", optional_argument, NULL, SETMASK_SIGNAL_OPTION}, {"debug", no_argument, NULL, 'v'}, {"split-string", required_argument, NULL, 'S'}, {GETOPT_HELP_OPTION_DECL}, @@ -110,6 +121,15 @@ Set each NAME to VALUE in the environment and run COMMAND.\n\ -u, --unset=NAME remove variable from the environment\n\ "), stdout); fputs (_("\ + --block-signal[=SIG] block signal SIG.\n\ +"), stdout); + fputs (_("\ + --unblock-signal[=SIG] unblock signal SIG.\n\ +"), stdout); + fputs (_("\ + --setmask-signal[=SIG] set blocked signal(s) mask to SIG.\n\ +"), stdout); + fputs (_("\ -C, --chdir=DIR change working directory to DIR\n\ "), stdout); fputs (_("\ @@ -649,6 +669,84 @@ reset_signal_handlers (void) } } +static void +parse_block_signal_params (const char* optarg, bool block) +{ + char signame[SIG2STR_MAX]; + char *opt_sig; + char *optarg_writable; + + if (! optarg) + { + /* without an argument, reset all signals. */ + sigfillset (block ? &block_signals : &unblock_signals); + sigemptyset (block ? &unblock_signals : &block_signals); + return; + } + + optarg_writable = xstrdup (optarg); + + opt_sig = strtok (optarg_writable, ","); + while (opt_sig) + { + int signum = operand2sig (opt_sig, signame); + /* operand2sig accepts signal 0 (EXIT) - but we reject it. */ + if (signum == 0) + error (0, 0, _("%s: invalid signal"), quote (opt_sig)); + if (signum <= 0) + usage (exit_failure); + + sigaddset (block ? &block_signals : &unblock_signals, signum); + sigdelset (block ? &unblock_signals : &block_signals, signum); + + opt_sig = strtok (NULL, ","); + } + + free (optarg_writable); +} + +static void +set_signal_proc_mask (void) +{ + /* Get the existing signal mask */ + sigset_t set; + const char *debug_act; + + sigemptyset (&set); + + if (sigprocmask (0, NULL, &set)) + die (EXIT_CANCELED, errno, _("failed to get signal process mask")); + + for (int i = 1; i < SIGNUM_BOUND; i++) + { + if (sigismember (&block_signals, i)) + { + sigaddset (&set, i); + debug_act = "BLOCK"; + } + else if (sigismember (&unblock_signals, i)) + { + sigdelset (&set, i); + debug_act = "UNBLOCK"; + } + else + { + debug_act = NULL; + } + + if (dev_debug && debug_act) + { + char signame[SIG2STR_MAX]; + sig2str (i, signame); + devmsg ("signal %s (%d) procmask set to %s\n", + signame, i, debug_act); + } + } + + if (sigprocmask (SIG_SETMASK, &set, NULL)) + die (EXIT_CANCELED, errno, _("failed to set signal process mask")); +} + int main (int argc, char **argv) { @@ -692,6 +790,17 @@ main (int argc, char **argv) case IGNORE_SIGNAL_OPTION: parse_signal_action_params (optarg, false); break; + case BLOCK_SIGNAL_OPTION: + parse_block_signal_params (optarg, true); + break; + case UNBLOCK_SIGNAL_OPTION: + parse_block_signal_params (optarg, false); + break; + case SETMASK_SIGNAL_OPTION: + sigfillset (&unblock_signals); + sigemptyset (&block_signals); + parse_block_signal_params (optarg, true); + break; case 'C': newdir = optarg; break; @@ -768,6 +877,7 @@ main (int argc, char **argv) } reset_signal_handlers (); + set_signal_proc_mask (); if (newdir) { -- 2.11.0 --------------C3D7A90883F10EA2249DFCA6 Content-Type: text/x-patch; name="0003-env-add-list-blocked-signals-list-signal-actions-opt.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0003-env-add-list-blocked-signals-list-signal-actions-opt.pa"; filename*1="tch" >From 150c30aec340d6ce00afa1251e6962c012449407 Mon Sep 17 00:00:00 2001 From: Assaf Gordon Date: Mon, 25 Feb 2019 18:03:19 -0700 Subject: [PATCH 3/3] env: add --list-blocked-signals/--list-signal-actions options Example: $ ( trap '' PIPE && env --list-signal-actions ) PIPE (13): ignore * NEWS: Mention new options. * doc/coreutils.texi (env invocation): Mention new options. * src/env.c (longopts,usage): Add new options. (list_signal_actions, list_blocked_signals): New functions. (main): Handle new options. --- NEWS | 3 +++ doc/coreutils.texi | 8 ++++++ src/env.c | 73 +++++++++++++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 83 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index cb8aa107f..3cef6066e 100644 --- a/NEWS +++ b/NEWS @@ -87,6 +87,9 @@ GNU coreutils NEWS -*- outline -*- env now supports '--{block,unblock,setmask}-singal[=SIG]' to block/unblock signal delivery before executing a program. + env now supports '--list-signal-actions' and '--list-blocked-signals' + options. + ** New commands basenc is added to complement existing base64,base32 commands, diff --git a/doc/coreutils.texi b/doc/coreutils.texi index 8f5212a72..b63161803 100644 --- a/doc/coreutils.texi +++ b/doc/coreutils.texi @@ -17309,6 +17309,14 @@ Unblock signal @var{sig}. Set list of blocked signals to @var{sig}. All other signals will be unblocked. +@item --list-signal-actions +List non-default actions for all signals and exit. +If all signals are set to their default action, nothing is printed. + +@item --list-blocked-signals +List blocked (masked) signals and exit. +If no signals are blocked, nothing is printed. + @item -p Equivalent to @option{--default-signal=PIPE} - sets SIGPIPE to its default diff --git a/src/env.c b/src/env.c index 4cae7d47f..43856200f 100644 --- a/src/env.c +++ b/src/env.c @@ -78,7 +78,9 @@ enum IGNORE_SIGNAL_OPTION, BLOCK_SIGNAL_OPTION, UNBLOCK_SIGNAL_OPTION, - SETMASK_SIGNAL_OPTION + SETMASK_SIGNAL_OPTION, + LIST_SIGNAL_ACTIONS_OPTION, + LIST_BLOCKED_SIGNALS_OPTION, }; static struct option const longopts[] = @@ -89,9 +91,11 @@ static struct option const longopts[] = {"chdir", required_argument, NULL, 'C'}, {"default-signal", optional_argument, NULL, DEFAULT_SIGNAL_OPTION}, {"ignore-signal", optional_argument, NULL, IGNORE_SIGNAL_OPTION}, + {"list-signal-actions", no_argument, NULL, LIST_SIGNAL_ACTIONS_OPTION}, {"block-signal", optional_argument, NULL, BLOCK_SIGNAL_OPTION}, {"unblock-signal", optional_argument, NULL, UNBLOCK_SIGNAL_OPTION}, {"setmask-signal", optional_argument, NULL, SETMASK_SIGNAL_OPTION}, + {"list-blocked-signals", no_argument, NULL, LIST_BLOCKED_SIGNALS_OPTION}, {"debug", no_argument, NULL, 'v'}, {"split-string", required_argument, NULL, 'S'}, {GETOPT_HELP_OPTION_DECL}, @@ -143,6 +147,15 @@ Set each NAME to VALUE in the environment and run COMMAND.\n\ used to pass multiple arguments on shebang lines\n\ "), stdout); fputs (_("\ + --list-signal-actions list non-default actions for signals and exit.\n\ + if all signals use their default actions,\n\ + nothing is printed.\n\ +"), stdout); + fputs (_("\ + --list-blocked-signals list blocked (masked) signals and exit.\n\ + if no signals are blocked, nothing is printed.\n\ +"), stdout); + fputs (_("\ -p same as --default-signal=PIPE\n\ "), stdout); fputs (_("\ @@ -670,6 +683,35 @@ reset_signal_handlers (void) } static void +list_signal_actions (void) +{ + char signame[SIG2STR_MAX]; + const char* action; + + for (int i = 1; i < SIGNUM_BOUND; i++) + { + struct sigaction act; + if (sigaction (i, NULL, &act)) + continue; + + if (act.sa_flags & SA_SIGINFO) + action = "sig-action"; + else if (act.sa_handler == SIG_DFL) + continue; /* no need to print defaults. */ + else if (act.sa_handler == SIG_IGN) + action = "ignore"; + else + action = "sig-handler"; + + sig2str (i, signame); + printf ("%-10s (%2d): %s\n", signame, i, action); + } + + exit (EXIT_SUCCESS); +} + + +static void parse_block_signal_params (const char* optarg, bool block) { char signame[SIG2STR_MAX]; @@ -747,6 +789,29 @@ set_signal_proc_mask (void) die (EXIT_CANCELED, errno, _("failed to set signal process mask")); } +static void +list_blocked_signals (void) +{ + sigset_t set; + char signame[SIG2STR_MAX]; + + sigemptyset (&set); + if (sigprocmask (0, NULL, &set)) + die (EXIT_CANCELED, errno, _("failed to get signal process mask")); + + for (int i = 1; i < SIGNUM_BOUND; i++) + { + if (!sigismember (&set, i)) + continue; + + sig2str (i, signame); + printf ("%-10s (%2d)\n", signame, i); + } + + exit (EXIT_SUCCESS); +} + + int main (int argc, char **argv) { @@ -790,6 +855,9 @@ main (int argc, char **argv) case IGNORE_SIGNAL_OPTION: parse_signal_action_params (optarg, false); break; + case LIST_SIGNAL_ACTIONS_OPTION: + list_signal_actions (); + break; case BLOCK_SIGNAL_OPTION: parse_block_signal_params (optarg, true); break; @@ -801,6 +869,9 @@ main (int argc, char **argv) sigemptyset (&block_signals); parse_block_signal_params (optarg, true); break; + case LIST_BLOCKED_SIGNALS_OPTION: + list_blocked_signals (); + break; case 'C': newdir = optarg; break; -- 2.11.0 --------------C3D7A90883F10EA2249DFCA6-- From unknown Sun Jun 15 01:09:57 2025 X-Loop: help-debbugs@gnu.org Subject: bug#34488: Add sort --limit, or document workarounds for sort|head error messages Resent-From: =?UTF-8?Q?P=C3=A1draig?= Brady Original-Sender: "Debbugs-submit" Resent-CC: bug-coreutils@gnu.org Resent-Date: Tue, 26 Feb 2019 06:36:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 34488 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: To: Assaf Gordon , Paul Eggert Cc: 34488@debbugs.gnu.org, Bernhard Voelker , Eric Blake , =?UTF-8?Q?=E7=A9=8D=E4=B8=B9=E5=B0=BC?= Dan Jacobson Received: via spool by 34488-submit@debbugs.gnu.org id=B34488.155116292725926 (code B ref 34488); Tue, 26 Feb 2019 06:36:01 +0000 Received: (at 34488) by debbugs.gnu.org; 26 Feb 2019 06:35:27 +0000 Received: from localhost ([127.0.0.1]:52221 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gyWKs-0006k5-IN for submit@debbugs.gnu.org; Tue, 26 Feb 2019 01:35:27 -0500 Received: from mail.magicbluesmoke.com ([82.195.144.49]:38204) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gyWKq-0006jw-Pn for 34488@debbugs.gnu.org; Tue, 26 Feb 2019 01:35:25 -0500 Received: from localhost.localdomain (unknown [76.21.115.186]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.magicbluesmoke.com (Postfix) with ESMTPSA id 8577B9A43; Tue, 26 Feb 2019 06:35:21 +0000 (GMT) References: <87mumxf6xn.fsf@jidanni.org> <49916778-4758-d040-5fcc-6e277a2dc183@redhat.com> <5b729a22-c3fa-b2b8-f204-ef27ed3a7292@gmail.com> <17f89f02-d446-d964-ffd4-2aae65b411a9@gmail.com> <2d93c9af-d335-21b4-77c2-071532e32c66@cs.ucla.edu> <5b099892-8773-2794-b8f3-437c79a65a5f@gmail.com> <73fbf04f-c237-6a5a-584d-8152cc079f09@cs.ucla.edu> <514735cd-d8de-7f5d-f588-3c15856f1cdc@draigBrady.com> <683b367c-2b3b-1869-af8c-40d5a77370c3@gmail.com> <97dbf933-4bf9-0350-21c4-c4fc87ea788a@cs.ucla.edu> <20151538-6173-bb98-f719-325a8b1724d6@gmail.com> From: =?UTF-8?Q?P=C3=A1draig?= Brady Message-ID: <1553a086-b917-bd6f-0ed4-713eb27ebc36@draigBrady.com> Date: Mon, 25 Feb 2019 22:35:19 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 In-Reply-To: <20151538-6173-bb98-f719-325a8b1724d6@gmail.com> Content-Type: multipart/mixed; boundary="------------3AEFAEABCE92EA7231CB8918" X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) This is a multi-part message in MIME format. --------------3AEFAEABCE92EA7231CB8918 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Thanks for doing all that. I've attached a few changes: - spelling fixes - usage() clarified/reordered - ensure sigset_t are initialized - Don't setprocmask() unless specified - Simplified SETMASK_SIGNAL_OPTION handling - The test missed `env` as a prerequisite - The test was slow/spun cpu, so used sleep instead of seq - Used $SHELL in case sh didn't support trap I see that the last signal that `kill -l` lists is not included. I think we should be processing SIGNUM_BOUND also? cheers, Pádraig --------------3AEFAEABCE92EA7231CB8918 Content-Type: text/x-patch; name="env-signal-fixes.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="env-signal-fixes.patch" >From f54e67f2a9dcc4db287c31969e99899582f53a88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A1draig=20Brady?= Date: Mon, 25 Feb 2019 22:30:09 -0800 Subject: [PATCH] env: misc signal handling fixes spelling fixes usage() clarified/reordered ensure sigset_t are initialized Don't setprocmask() unless specified Simplified SETMASK_SIGNAL_OPTION handling test missed `env` as a prerequisite test was slow/spun cpu, so used sleep instead of seq Used $SHELL in case sh didn't support trap --- NEWS | 4 ++-- doc/coreutils.texi | 6 +++--- man/env.x | 4 ++-- src/env.c | 46 +++++++++++++++++++++++----------------- tests/misc/env-signal-handler.sh | 33 ++++++++++++---------------- 5 files changed, 47 insertions(+), 46 deletions(-) diff --git a/NEWS b/NEWS index c310d1f..e090c72 100644 --- a/NEWS +++ b/NEWS @@ -67,10 +67,10 @@ GNU coreutils NEWS -*- outline -*- test now supports the '-N FILE' unary operator (like e.g. bash) to check whether FILE exists and has been modified since it was last read. - env now supports '--default-singal[=SIG]' and '--ignore-signal[=SIG]' + env now supports '--default-signal[=SIG]' and '--ignore-signal[=SIG]' options to set signal handlers before executing a program. - env now supports '--{block,unblock,setmask}-singal[=SIG]' to block/unblock + env now supports '--{block,unblock,setmask}-signal[=SIG]' to block/unblock signal delivery before executing a program. env now supports '--list-signal-actions' and '--list-blocked-signals' diff --git a/doc/coreutils.texi b/doc/coreutils.texi index 5199b83..30a5990 100644 --- a/doc/coreutils.texi +++ b/doc/coreutils.texi @@ -17274,7 +17274,7 @@ Most operating systems do not allow ignoring @samp{SIGKILL}, @samp{SIGSTOP} Multiple (and contradictory) @option{--default-signal=SIG} and @option{--ignore-signal=SIG} options are processed left-to-right, -with the latter taking precedence. In the follwing example, @samp{SIGPIPE} is +with the latter taking precedence. In the following example, @samp{SIGPIPE} is set to default while @samp{SIGINT} is ignored: @example @@ -17282,10 +17282,10 @@ env --default-signal=INT,PIPE --ignore-signal=INT @end example @item --block-signal[=@var{sig}] -Block signal @var{sig} from being delivered. +Block signal(s) @var{sig} from being delivered. @item --unblock-signal[=@var{sig}] -Unblock signal @var{sig}. +Unblock signal(s) @var{sig}. @item --setmask-signal[=@var{sig}] Set list of blocked signals to @var{sig}. All other signals will be unblocked. diff --git a/man/env.x b/man/env.x index b787fe3..b2eb371 100644 --- a/man/env.x +++ b/man/env.x @@ -38,7 +38,7 @@ parameter the script will likely fail with: .PP See the full documentation for more details. .PP -.SS "\-\-default-signal[=SIG]" to 'untrap' a singal +.SS "\-\-default-signal[=SIG]" to 'untrap' a signal This option allows setting a signal handler to its default action. This is useful to reset a signal after setting it to 'ignore' using the shell's trap command. @@ -87,7 +87,7 @@ Multiple (and contradictory) and .B \-\-ignore\-signal=SIG options are processed left-to-right, with the latter taking precedence. -In the follwing example, SIGPIPE is set to default while SIGINT is ignored: +In the following example, SIGPIPE is set to default while SIGINT is ignored: .RS .nf env \-\-default\-signal=INT,PIPE \-\-ignore\-signal=INT diff --git a/src/env.c b/src/env.c index 4385620..1acfc11 100644 --- a/src/env.c +++ b/src/env.c @@ -67,6 +67,8 @@ static sigset_t block_signals; /* Set of signals to unblock. */ static sigset_t unblock_signals; +/* Whether signal mask adjustment requested. */ +static bool sig_mask_changed; static char const shortopts[] = "+C:ipS:u:v0 \t"; @@ -125,35 +127,32 @@ Set each NAME to VALUE in the environment and run COMMAND.\n\ -u, --unset=NAME remove variable from the environment\n\ "), stdout); fputs (_("\ - --block-signal[=SIG] block signal SIG.\n\ + -C, --chdir=DIR change working directory to DIR\n\ "), stdout); fputs (_("\ - --unblock-signal[=SIG] unblock signal SIG.\n\ + -S, --split-string=S process and split S into separate arguments;\n\ + used to pass multiple arguments on shebang lines\n\ "), stdout); fputs (_("\ - --setmask-signal[=SIG] set blocked signal(s) mask to SIG.\n\ + --block-signal[=SIG] block delivery of SIG signal(s) to COMMAND\n\ "), stdout); fputs (_("\ - -C, --chdir=DIR change working directory to DIR\n\ + --unblock-signal[=SIG] unblock delivery of SIG signal(s) to COMMAND\n\ "), stdout); fputs (_("\ - --default-signal[=SIG] set signal SIG to its default action.\n\ + --setmask-signal[=SIG] set full mask with SIG signal(s) blocked\n\ "), stdout); fputs (_("\ - --ignore-signal[=SIG] set signal SIG to be ignored.\n\ + --default-signal[=SIG] reset handling of SIG signal(s) to the default\n\ "), stdout); fputs (_("\ - -S, --split-string=S process and split S into separate arguments;\n\ - used to pass multiple arguments on shebang lines\n\ + --ignore-signal[=SIG] set handling of SIG signals(s) to do nothing\n\ "), stdout); fputs (_("\ - --list-signal-actions list non-default actions for signals and exit.\n\ - if all signals use their default actions,\n\ - nothing is printed.\n\ + --list-signal-actions list signals with non-default actions and exit\n\ "), stdout); fputs (_("\ - --list-blocked-signals list blocked (masked) signals and exit.\n\ - if no signals are blocked, nothing is printed.\n\ + --list-blocked-signals list blocked (masked) signals and exit\n\ "), stdout); fputs (_("\ -p same as --default-signal=PIPE\n\ @@ -172,7 +171,6 @@ A mere - implies -i. If no COMMAND, print the resulting environment.\n\ SIG may be a signal name like 'PIPE', or a signal number like '13'.\n\ Without SIG, all known signals are included. Multiple signals can be\n\ comma-separated.\n\ -\n\ "), stdout); emit_ancillary_info (PROGRAM_NAME); } @@ -723,8 +721,18 @@ parse_block_signal_params (const char* optarg, bool block) /* without an argument, reset all signals. */ sigfillset (block ? &block_signals : &unblock_signals); sigemptyset (block ? &unblock_signals : &block_signals); - return; } + else if (! sig_mask_changed) + { + /* Initialize the sets. */ + sigemptyset (&block_signals); + sigemptyset (&unblock_signals); + } + + sig_mask_changed = true; + + if (! optarg) + return; optarg_writable = xstrdup (optarg); @@ -780,7 +788,7 @@ set_signal_proc_mask (void) { char signame[SIG2STR_MAX]; sig2str (i, signame); - devmsg ("signal %s (%d) procmask set to %s\n", + devmsg ("signal %s (%d) mask set to %s\n", signame, i, debug_act); } } @@ -865,8 +873,7 @@ main (int argc, char **argv) parse_block_signal_params (optarg, false); break; case SETMASK_SIGNAL_OPTION: - sigfillset (&unblock_signals); - sigemptyset (&block_signals); + parse_block_signal_params (NULL, false); parse_block_signal_params (optarg, true); break; case LIST_BLOCKED_SIGNALS_OPTION: @@ -948,7 +955,8 @@ main (int argc, char **argv) } reset_signal_handlers (); - set_signal_proc_mask (); + if (sig_mask_changed) + set_signal_proc_mask (); if (newdir) { diff --git a/tests/misc/env-signal-handler.sh b/tests/misc/env-signal-handler.sh index b531549..4dd90c2 100755 --- a/tests/misc/env-signal-handler.sh +++ b/tests/misc/env-signal-handler.sh @@ -17,9 +17,7 @@ # along with this program. If not, see . . "${srcdir=.}/tests/init.sh"; path_prepend_ ./src -print_ver_ seq -print_ver_ timeout -print_ver_ test +print_ver_ env seq test timeout trap_sigpipe_or_skip_ # Paraphrasing http://bugs.gnu.org/34488#8: @@ -40,7 +38,7 @@ trap_sigpipe_or_skip_ # sets SIGPIPE to ignore, and the second 'trap' becomes a no-op instead # of resetting SIGPIPE to its default). Upon a SIGPIPE 'seq' will not be # terminated, instead its write(2) call will return an error. -(trap '' PIPE; sh -c 'trap - PIPE; seq 999999 2>err1t | head -n1 > out1') +(trap '' PIPE; $SHELL -c 'trap - PIPE; seq 999999 2>err1t | head -n1 > out1') # The exact broken pipe message depends on the operating system, just ensure # there was a 'write error' message in stderr: @@ -60,7 +58,7 @@ compare exp-err1 err1 || framework_failure_ # 'seq' program): (trap '' PIPE; env --default-signal=PIPE \ - sh -c 'trap - PIPE; seq 999999 2>err2 | head -n1 > out2') + $SHELL -c 'trap - PIPE; seq 999999 2>err2 | head -n1 > out2') compare exp-out out2 || fail=1 compare /dev/null err2 || fail=1 @@ -70,7 +68,7 @@ compare /dev/null err2 || fail=1 # Repeat the previous test, using "-p" (shortcut for --default-signal=PIPE): (trap '' PIPE; env -p \ - sh -c 'trap - PIPE; seq 999999 2>err3 | head -n1 > out3') + $SHELL -c 'trap - PIPE; seq 999999 2>err3 | head -n1 > out3') compare exp-out out3 || fail=1 compare /dev/null err3 || fail=1 @@ -81,25 +79,21 @@ compare /dev/null err3 || fail=1 # i.e., all signals. (trap '' PIPE; env --default-signal \ - sh -c 'trap - PIPE; seq 999999 2>err4 | head -n1 > out4') + $SHELL -c 'trap - PIPE; seq 999999 2>err4 | head -n1 > out4') compare exp-out out4 || fail=1 compare /dev/null err4 || fail=1 - - - - # Baseline test - ignore signal handler # ------------------------------------- -# Kill 'seq' after 1 second with SIGINT - it should terminate (as SIGINT's +# Kill 'sleep' after 1 second with SIGINT - it should terminate (as SIGINT's # default action is to terminate a program). # (The first 'env' is just to ensure timeout is not the shell's built-in.) -env timeout --verbose --kill-after=1 --signal=INT 1 \ - seq inf > /dev/null 2>err5 +env timeout --verbose --kill-after=.1 --signal=INT .1 \ + sleep 10 > /dev/null 2>err5 -printf "timeout: sending signal INT to command 'seq'\n" > exp-err5 \ +printf "timeout: sending signal INT to command 'sleep'\n" > exp-err5 \ || framework_failure_ compare exp-err5 err5 || fail=1 @@ -115,9 +109,9 @@ timeout: sending signal INT to command 'env' timeout: sending signal KILL to command 'env' EOF -env timeout --verbose --kill-after=1 --signal=INT 1 \ +env timeout --verbose --kill-after=.1 --signal=INT .1 \ env --ignore-signal=INT \ - seq inf > /dev/null 2>err6t + sleep 10 > /dev/null 2>err6t # check only the first two lines from stderr, which are printed by timeout. # (operating systems might add more messages, like "killed"). @@ -131,9 +125,9 @@ compare exp-err6 err6 || fail=1 # Repeat the previous test with "--ignore-signals" and no signal names, # i.e., all signals. -env timeout --verbose --kill-after=1 --signal=INT 1 \ +env timeout --verbose --kill-after=.1 --signal=INT .1 \ env --ignore-signal \ - seq inf > /dev/null 2>err7t + sleep 10 > /dev/null 2>err7t # check only the first two lines from stderr, which are printed by timeout. # (operating systems might add more messages, like "killed"). @@ -142,5 +136,4 @@ sed -n '1,2p' err7t > err7 || framework_failure_ compare exp-err6 err7 || fail=1 - Exit $fail -- 2.9.3 --------------3AEFAEABCE92EA7231CB8918-- From unknown Sun Jun 15 01:09:57 2025 X-Loop: help-debbugs@gnu.org Subject: bug#34488: Add sort --limit, or document workarounds for sort|head error messages Resent-From: =?UTF-8?Q?P=C3=A1draig?= Brady Original-Sender: "Debbugs-submit" Resent-CC: bug-coreutils@gnu.org Resent-Date: Sun, 03 Mar 2019 23:37:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 34488 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: To: Assaf Gordon Cc: 34488@debbugs.gnu.org Received: via spool by 34488-submit@debbugs.gnu.org id=B34488.155165617914802 (code B ref 34488); Sun, 03 Mar 2019 23:37:02 +0000 Received: (at 34488) by debbugs.gnu.org; 3 Mar 2019 23:36:19 +0000 Received: from localhost ([127.0.0.1]:58783 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1h0aeZ-0003qf-0i for submit@debbugs.gnu.org; Sun, 03 Mar 2019 18:36:19 -0500 Received: from mail.magicbluesmoke.com ([82.195.144.49]:38796) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1h0aeW-0003qV-KK for 34488@debbugs.gnu.org; Sun, 03 Mar 2019 18:36:17 -0500 Received: from localhost.localdomain (unknown [76.21.115.186]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.magicbluesmoke.com (Postfix) with ESMTPSA id E44309E56; Sun, 3 Mar 2019 23:36:14 +0000 (GMT) References: <87mumxf6xn.fsf@jidanni.org> <49916778-4758-d040-5fcc-6e277a2dc183@redhat.com> <5b729a22-c3fa-b2b8-f204-ef27ed3a7292@gmail.com> <17f89f02-d446-d964-ffd4-2aae65b411a9@gmail.com> <2d93c9af-d335-21b4-77c2-071532e32c66@cs.ucla.edu> <5b099892-8773-2794-b8f3-437c79a65a5f@gmail.com> <73fbf04f-c237-6a5a-584d-8152cc079f09@cs.ucla.edu> <514735cd-d8de-7f5d-f588-3c15856f1cdc@draigBrady.com> <683b367c-2b3b-1869-af8c-40d5a77370c3@gmail.com> <97dbf933-4bf9-0350-21c4-c4fc87ea788a@cs.ucla.edu> <20151538-6173-bb98-f719-325a8b1724d6@gmail.com> <1553a086-b917-bd6f-0ed4-713eb27ebc36@draigBrady.com> From: =?UTF-8?Q?P=C3=A1draig?= Brady Message-ID: <1be1da7d-89c9-a270-1c44-92940feb270b@draigBrady.com> Date: Sun, 3 Mar 2019 15:36:12 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 In-Reply-To: <1553a086-b917-bd6f-0ed4-713eb27ebc36@draigBrady.com> Content-Type: multipart/mixed; boundary="------------17555B1A70AEA408A77A0AC9" X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) This is a multi-part message in MIME format. --------------17555B1A70AEA408A77A0AC9 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit On 25/02/19 22:35, Pádraig Brady wrote: > Thanks for doing all that. > I've attached a few changes: > > - spelling fixes > - usage() clarified/reordered > - ensure sigset_t are initialized > - Don't setprocmask() unless specified > - Simplified SETMASK_SIGNAL_OPTION handling > - The test missed `env` as a prerequisite > - The test was slow/spun cpu, so used sleep instead of seq > - Used $SHELL in case sh didn't support trap > > I see that the last signal that `kill -l` lists is not included. > I think we should be processing SIGNUM_BOUND also? An additional patch attached to replace --list-signal-actions with --list-ignored-signals. This is simpler, and more symmetric with the other options. Also the extra output was moot I think since handlers are reset upon exec. For completeness the transitions are: upon fork default -> default handled -> handled ignored -> ignored pending -> cleared blocked -> blocked upon exec default -> default handled -> default ignored -> ignored pending -> pending blocked -> blocked shell has additional rules: can't unignore handled -> default in subshell I'll squash this into yours, before commit. cheers, Pádraig --------------17555B1A70AEA408A77A0AC9 Content-Type: text/x-patch; name="env-list-ignored.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="env-list-ignored.patch" >From a8e531b15a2e85ecf7d18526bfbb7990537621b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A1draig=20Brady?= Date: Sun, 3 Mar 2019 15:29:59 -0800 Subject: [PATCH] env: use --list-ignored-signals instead of --list-signals-action This is more symmetric and anyway signal handlers are reset upon exec(), so the more complicated reporting is moot. --- src/env.c | 60 ++++++++++++++++++++++++++---------------------------------- 1 file changed, 26 insertions(+), 34 deletions(-) diff --git a/src/env.c b/src/env.c index 1acfc11..74043b1 100644 --- a/src/env.c +++ b/src/env.c @@ -81,8 +81,8 @@ enum BLOCK_SIGNAL_OPTION, UNBLOCK_SIGNAL_OPTION, SETMASK_SIGNAL_OPTION, - LIST_SIGNAL_ACTIONS_OPTION, LIST_BLOCKED_SIGNALS_OPTION, + LIST_IGNORED_SIGNALS_OPTION, }; static struct option const longopts[] = @@ -93,11 +93,11 @@ static struct option const longopts[] = {"chdir", required_argument, NULL, 'C'}, {"default-signal", optional_argument, NULL, DEFAULT_SIGNAL_OPTION}, {"ignore-signal", optional_argument, NULL, IGNORE_SIGNAL_OPTION}, - {"list-signal-actions", no_argument, NULL, LIST_SIGNAL_ACTIONS_OPTION}, {"block-signal", optional_argument, NULL, BLOCK_SIGNAL_OPTION}, {"unblock-signal", optional_argument, NULL, UNBLOCK_SIGNAL_OPTION}, {"setmask-signal", optional_argument, NULL, SETMASK_SIGNAL_OPTION}, {"list-blocked-signals", no_argument, NULL, LIST_BLOCKED_SIGNALS_OPTION}, + {"list-ignored-signals", no_argument, NULL, LIST_IGNORED_SIGNALS_OPTION}, {"debug", no_argument, NULL, 'v'}, {"split-string", required_argument, NULL, 'S'}, {GETOPT_HELP_OPTION_DECL}, @@ -149,7 +149,7 @@ Set each NAME to VALUE in the environment and run COMMAND.\n\ --ignore-signal[=SIG] set handling of SIG signals(s) to do nothing\n\ "), stdout); fputs (_("\ - --list-signal-actions list signals with non-default actions and exit\n\ + --list-ignored-signals list ignored signals and exit\n\ "), stdout); fputs (_("\ --list-blocked-signals list blocked (masked) signals and exit\n\ @@ -680,34 +680,6 @@ reset_signal_handlers (void) } } -static void -list_signal_actions (void) -{ - char signame[SIG2STR_MAX]; - const char* action; - - for (int i = 1; i < SIGNUM_BOUND; i++) - { - struct sigaction act; - if (sigaction (i, NULL, &act)) - continue; - - if (act.sa_flags & SA_SIGINFO) - action = "sig-action"; - else if (act.sa_handler == SIG_DFL) - continue; /* no need to print defaults. */ - else if (act.sa_handler == SIG_IGN) - action = "ignore"; - else - action = "sig-handler"; - - sig2str (i, signame); - printf ("%-10s (%2d): %s\n", signame, i, action); - } - - exit (EXIT_SUCCESS); -} - static void parse_block_signal_params (const char* optarg, bool block) @@ -819,6 +791,26 @@ list_blocked_signals (void) exit (EXIT_SUCCESS); } +static void +list_ignored_signals (void) +{ + char signame[SIG2STR_MAX]; + + for (int i = 1; i < SIGNUM_BOUND; i++) + { + struct sigaction act; + if (sigaction (i, NULL, &act)) + continue; + + if (act.sa_handler != SIG_IGN) + continue; + + sig2str (i, signame); + printf ("%-10s (%2d)\n", signame, i); + } + + exit (EXIT_SUCCESS); +} int main (int argc, char **argv) @@ -863,9 +855,6 @@ main (int argc, char **argv) case IGNORE_SIGNAL_OPTION: parse_signal_action_params (optarg, false); break; - case LIST_SIGNAL_ACTIONS_OPTION: - list_signal_actions (); - break; case BLOCK_SIGNAL_OPTION: parse_block_signal_params (optarg, true); break; @@ -879,6 +868,9 @@ main (int argc, char **argv) case LIST_BLOCKED_SIGNALS_OPTION: list_blocked_signals (); break; + case LIST_IGNORED_SIGNALS_OPTION: + list_ignored_signals (); + break; case 'C': newdir = optarg; break; -- 2.9.3 --------------17555B1A70AEA408A77A0AC9-- From unknown Sun Jun 15 01:09:57 2025 X-Loop: help-debbugs@gnu.org Subject: bug#34488: Add sort --limit, or document workarounds for sort|head error messages Resent-From: =?UTF-8?Q?P=C3=A1draig?= Brady Original-Sender: "Debbugs-submit" Resent-CC: bug-coreutils@gnu.org Resent-Date: Mon, 04 Mar 2019 00:08:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 34488 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: To: Assaf Gordon Cc: 34488@debbugs.gnu.org Received: via spool by 34488-submit@debbugs.gnu.org id=B34488.155165806617448 (code B ref 34488); Mon, 04 Mar 2019 00:08:01 +0000 Received: (at 34488) by debbugs.gnu.org; 4 Mar 2019 00:07:46 +0000 Received: from localhost ([127.0.0.1]:58789 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1h0b8z-0004XM-O8 for submit@debbugs.gnu.org; Sun, 03 Mar 2019 19:07:46 -0500 Received: from mail.magicbluesmoke.com ([82.195.144.49]:38886) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1h0b8x-0004XC-03 for 34488@debbugs.gnu.org; Sun, 03 Mar 2019 19:07:43 -0500 Received: from localhost.localdomain (unknown [76.21.115.186]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.magicbluesmoke.com (Postfix) with ESMTPSA id 6B81CA230; Mon, 4 Mar 2019 00:07:41 +0000 (GMT) References: <87mumxf6xn.fsf@jidanni.org> <49916778-4758-d040-5fcc-6e277a2dc183@redhat.com> <5b729a22-c3fa-b2b8-f204-ef27ed3a7292@gmail.com> <17f89f02-d446-d964-ffd4-2aae65b411a9@gmail.com> <2d93c9af-d335-21b4-77c2-071532e32c66@cs.ucla.edu> <5b099892-8773-2794-b8f3-437c79a65a5f@gmail.com> <73fbf04f-c237-6a5a-584d-8152cc079f09@cs.ucla.edu> <514735cd-d8de-7f5d-f588-3c15856f1cdc@draigBrady.com> <683b367c-2b3b-1869-af8c-40d5a77370c3@gmail.com> <97dbf933-4bf9-0350-21c4-c4fc87ea788a@cs.ucla.edu> <20151538-6173-bb98-f719-325a8b1724d6@gmail.com> <1553a086-b917-bd6f-0ed4-713eb27ebc36@draigBrady.com> <1be1da7d-89c9-a270-1c44-92940feb270b@draigBrady.com> From: =?UTF-8?Q?P=C3=A1draig?= Brady Message-ID: <5933d27b-93d6-66dc-cbad-ae2f61e19aa2@draigBrady.com> Date: Sun, 3 Mar 2019 16:07:39 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 In-Reply-To: <1be1da7d-89c9-a270-1c44-92940feb270b@draigBrady.com> Content-Type: multipart/mixed; boundary="------------56E5CB8024733452B8E693B0" X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) This is a multi-part message in MIME format. --------------56E5CB8024733452B8E693B0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit On 03/03/19 15:36, Pádraig Brady wrote: > On 25/02/19 22:35, Pádraig Brady wrote: >> Thanks for doing all that. >> I've attached a few changes: >> >> - spelling fixes >> - usage() clarified/reordered >> - ensure sigset_t are initialized >> - Don't setprocmask() unless specified >> - Simplified SETMASK_SIGNAL_OPTION handling >> - The test missed `env` as a prerequisite >> - The test was slow/spun cpu, so used sleep instead of seq >> - Used $SHELL in case sh didn't support trap >> >> I see that the last signal that `kill -l` lists is not included. >> I think we should be processing SIGNUM_BOUND also? > > An additional patch attached to replace --list-signal-actions > with --list-ignored-signals. This is simpler, and more symmetric > with the other options. Also the extra output was moot I think > since handlers are reset upon exec I've locally adjusted the NEWS/texi for that patch also. I've a local patch to include SIGNUM_BOUND which I won't spam the list with. Attached is a patch to remove the -p and --set-mask options, which I've a light preference for. I'll think some more about it. cheers, Pádraig --------------56E5CB8024733452B8E693B0 Content-Type: text/x-patch; name="env-remove-shortcuts.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="env-remove-shortcuts.patch" >From ae8d2ab5d9a380051a1ae1d315832e98f40ff456 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A1draig=20Brady?= Date: Sun, 3 Mar 2019 16:02:55 -0800 Subject: [PATCH] env: remove shortcut signal handling options * src/env.c: Remove -p and --setmask-signal --- doc/coreutils.texi | 9 --------- src/env.c | 16 ---------------- tests/misc/env-signal-handler.sh | 10 ---------- 3 files changed, 35 deletions(-) diff --git a/doc/coreutils.texi b/doc/coreutils.texi index 4dea101..3c220ea 100644 --- a/doc/coreutils.texi +++ b/doc/coreutils.texi @@ -17305,10 +17305,6 @@ Block signal(s) @var{sig} from being delivered. @item --unblock-signal[=@var{sig}] Unblock signal(s) @var{sig}. -@item --setmask-signal[=@var{sig}] -Set list of blocked signals to @var{sig}. All other signals will be unblocked. - - @item --list-blocked-signals List blocked (masked) signals and exit. If no signals are blocked, nothing is printed. @@ -17317,11 +17313,6 @@ If no signals are blocked, nothing is printed. List ignored signals and exit. If no signals are ignored, nothing is printed. - -@item -p -Equivalent to @option{--default-signal=PIPE} - sets SIGPIPE to its default -behavior (terminate a program upon @samp{SIGPIPE}). - @item -v @itemx --debug @opindex -v diff --git a/src/env.c b/src/env.c index 90821c3..7bc3c7b 100644 --- a/src/env.c +++ b/src/env.c @@ -80,7 +80,6 @@ enum IGNORE_SIGNAL_OPTION, BLOCK_SIGNAL_OPTION, UNBLOCK_SIGNAL_OPTION, - SETMASK_SIGNAL_OPTION, LIST_BLOCKED_SIGNALS_OPTION, LIST_IGNORED_SIGNALS_OPTION, }; @@ -95,7 +94,6 @@ static struct option const longopts[] = {"ignore-signal", optional_argument, NULL, IGNORE_SIGNAL_OPTION}, {"block-signal", optional_argument, NULL, BLOCK_SIGNAL_OPTION}, {"unblock-signal", optional_argument, NULL, UNBLOCK_SIGNAL_OPTION}, - {"setmask-signal", optional_argument, NULL, SETMASK_SIGNAL_OPTION}, {"list-blocked-signals", no_argument, NULL, LIST_BLOCKED_SIGNALS_OPTION}, {"list-ignored-signals", no_argument, NULL, LIST_IGNORED_SIGNALS_OPTION}, {"debug", no_argument, NULL, 'v'}, @@ -140,9 +138,6 @@ Set each NAME to VALUE in the environment and run COMMAND.\n\ --unblock-signal[=SIG] unblock delivery of SIG signal(s) to COMMAND\n\ "), stdout); fputs (_("\ - --setmask-signal[=SIG] set full mask with SIG signal(s) blocked\n\ -"), stdout); - fputs (_("\ --default-signal[=SIG] reset handling of SIG signal(s) to the default\n\ "), stdout); fputs (_("\ @@ -155,9 +150,6 @@ Set each NAME to VALUE in the environment and run COMMAND.\n\ --list-blocked-signals list blocked (masked) signals and exit\n\ "), stdout); fputs (_("\ - -p same as --default-signal=PIPE\n\ -"), stdout); - fputs (_("\ -v, --debug print verbose information for each processing step\n\ "), stdout); fputs (HELP_OPTION_DESCRIPTION, stdout); @@ -845,10 +837,6 @@ main (int argc, char **argv) case '0': opt_nul_terminate_output = true; break; - case 'p': - /* alias to --default-signal=PIPE */ - signals[SIGPIPE] = DEFAULT; - break; case DEFAULT_SIGNAL_OPTION: parse_signal_action_params (optarg, true); break; @@ -861,10 +849,6 @@ main (int argc, char **argv) case UNBLOCK_SIGNAL_OPTION: parse_block_signal_params (optarg, false); break; - case SETMASK_SIGNAL_OPTION: - parse_block_signal_params (NULL, false); - parse_block_signal_params (optarg, true); - break; case LIST_BLOCKED_SIGNALS_OPTION: list_blocked_signals (); break; diff --git a/tests/misc/env-signal-handler.sh b/tests/misc/env-signal-handler.sh index 4dd90c2..5e6b57e 100755 --- a/tests/misc/env-signal-handler.sh +++ b/tests/misc/env-signal-handler.sh @@ -63,16 +63,6 @@ compare exp-err1 err1 || framework_failure_ compare exp-out out2 || fail=1 compare /dev/null err2 || fail=1 -# env test - default signal handler (2) -# ------------------------------------- -# Repeat the previous test, using "-p" (shortcut for --default-signal=PIPE): -(trap '' PIPE; - env -p \ - $SHELL -c 'trap - PIPE; seq 999999 2>err3 | head -n1 > out3') - -compare exp-out out3 || fail=1 -compare /dev/null err3 || fail=1 - # env test - default signal handler (3) # ------------------------------------- # Repeat the previous test, using --default-signal with no signal names, -- 2.9.3 --------------56E5CB8024733452B8E693B0-- From unknown Sun Jun 15 01:09:57 2025 X-Loop: help-debbugs@gnu.org Subject: bug#34488: Add sort --limit, or document workarounds for sort|head error messages Resent-From: =?UTF-8?Q?P=C3=A1draig?= Brady Original-Sender: "Debbugs-submit" Resent-CC: bug-coreutils@gnu.org Resent-Date: Mon, 04 Mar 2019 01:00:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 34488 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: To: Assaf Gordon Cc: 34488@debbugs.gnu.org Received: via spool by 34488-submit@debbugs.gnu.org id=B34488.155166117521941 (code B ref 34488); Mon, 04 Mar 2019 01:00:02 +0000 Received: (at 34488) by debbugs.gnu.org; 4 Mar 2019 00:59:35 +0000 Received: from localhost ([127.0.0.1]:58800 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1h0bx8-0005ho-Do for submit@debbugs.gnu.org; Sun, 03 Mar 2019 19:59:34 -0500 Received: from mail.magicbluesmoke.com ([82.195.144.49]:38982) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1h0bx6-0005hc-5X for 34488@debbugs.gnu.org; Sun, 03 Mar 2019 19:59:32 -0500 Received: from localhost.localdomain (unknown [76.21.115.186]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.magicbluesmoke.com (Postfix) with ESMTPSA id 4463AA63D; Mon, 4 Mar 2019 00:59:30 +0000 (GMT) References: <87mumxf6xn.fsf@jidanni.org> <49916778-4758-d040-5fcc-6e277a2dc183@redhat.com> <5b729a22-c3fa-b2b8-f204-ef27ed3a7292@gmail.com> <17f89f02-d446-d964-ffd4-2aae65b411a9@gmail.com> <2d93c9af-d335-21b4-77c2-071532e32c66@cs.ucla.edu> <5b099892-8773-2794-b8f3-437c79a65a5f@gmail.com> <73fbf04f-c237-6a5a-584d-8152cc079f09@cs.ucla.edu> <514735cd-d8de-7f5d-f588-3c15856f1cdc@draigBrady.com> <683b367c-2b3b-1869-af8c-40d5a77370c3@gmail.com> <97dbf933-4bf9-0350-21c4-c4fc87ea788a@cs.ucla.edu> <20151538-6173-bb98-f719-325a8b1724d6@gmail.com> <1553a086-b917-bd6f-0ed4-713eb27ebc36@draigBrady.com> <1be1da7d-89c9-a270-1c44-92940feb270b@draigBrady.com> <5933d27b-93d6-66dc-cbad-ae2f61e19aa2@draigBrady.com> From: =?UTF-8?Q?P=C3=A1draig?= Brady Message-ID: Date: Sun, 3 Mar 2019 16:59:28 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 In-Reply-To: <5933d27b-93d6-66dc-cbad-ae2f61e19aa2@draigBrady.com> Content-Type: multipart/mixed; boundary="------------BDFE3F77B504826D522D4A62" X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) This is a multi-part message in MIME format. --------------BDFE3F77B504826D522D4A62 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit On 03/03/19 16:07, Pádraig Brady wrote: > On 03/03/19 15:36, Pádraig Brady wrote: >> On 25/02/19 22:35, Pádraig Brady wrote: >>> Thanks for doing all that. >>> I've attached a few changes: >>> >>> - spelling fixes >>> - usage() clarified/reordered >>> - ensure sigset_t are initialized >>> - Don't setprocmask() unless specified >>> - Simplified SETMASK_SIGNAL_OPTION handling >>> - The test missed `env` as a prerequisite >>> - The test was slow/spun cpu, so used sleep instead of seq >>> - Used $SHELL in case sh didn't support trap >>> >>> I see that the last signal that `kill -l` lists is not included. >>> I think we should be processing SIGNUM_BOUND also? >> >> An additional patch attached to replace --list-signal-actions >> with --list-ignored-signals. This is simpler, and more symmetric >> with the other options. Also the extra output was moot I think >> since handlers are reset upon exec > > I've locally adjusted the NEWS/texi for that patch also. > I've a local patch to include SIGNUM_BOUND which I won't spam the list with. > > Attached is a patch to remove the -p and --set-mask options, > which I've a light preference for. > I'll think some more about it. Attached is a patch to combine the two --list options to a single --list-signal-handling option. This also doesn't exit, and so is more useful as users can add --list-signal to their env commands to diagnose signal handling. One can easily use `true` as the command to get the original list only functionality. A summary of the all signal options in my local set now is: --block-signal[=SIG] block delivery of SIG signal(s) to COMMAND --unblock-signal[=SIG] unblock delivery of SIG signal(s) to COMMAND --default-signal[=SIG] reset handling of SIG signal(s) to the default --ignore-signal[=SIG] set handling of SIG signals(s) to do nothing --list-signal-handling list non default signal handling to stderr cheers, Pádraig --------------BDFE3F77B504826D522D4A62 Content-Type: text/x-patch; name="env-single-list.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="env-single-list.patch" =46rom 715254df092d6e3dfac7bdfd72f7307dce21dabd Mon Sep 17 00:00:00 2001 From: =3D?UTF-8?q?P=3DC3=3DA1draig=3D20Brady?=3D Date: Sun, 3 Mar 2019 16:50:27 -0800 Subject: [PATCH] env: add only a single --list-signal-handling option This also doesn't exit, which is more useful as it directly confirms any inherited handling in combination with any signal settings we may have set. One can easily use `true` as the command to get the original list only functionality --- NEWS | 3 ++- doc/coreutils.texi | 5 ++--- src/env.c | 54 +++++++++++++++++++-----------------------------= ------ 3 files changed, 23 insertions(+), 39 deletions(-) diff --git a/NEWS b/NEWS index 33f1ef2..6fbc8f1 100644 --- a/NEWS +++ b/NEWS @@ -90,7 +90,8 @@ GNU coreutils NEWS -= *- outline -*- env now supports '--{block,unblock,setmask}-signal[=3DSIG]' to block/u= nblock signal delivery before executing a program. =20 - env now supports '--list-blocked-signals', and '--list-ignored-signals= '. + env now supports '--list-signal-handling' to identify signal handling + before executing a program. =20 ** New commands =20 diff --git a/doc/coreutils.texi b/doc/coreutils.texi index 3c220ea..0e4ed16 100644 --- a/doc/coreutils.texi +++ b/doc/coreutils.texi @@ -17309,9 +17309,8 @@ Unblock signal(s) @var{sig}. List blocked (masked) signals and exit. If no signals are blocked, nothing is printed. =20 -@item --list-ignored-signals -List ignored signals and exit. -If no signals are ignored, nothing is printed. +@item --list-signal-handling +List blocked or ignored signals to stderr, before executing a command. =20 @item -v @itemx --debug diff --git a/src/env.c b/src/env.c index 7bc3c7b..9a910da 100644 --- a/src/env.c +++ b/src/env.c @@ -70,6 +70,9 @@ static sigset_t unblock_signals; /* Whether signal mask adjustment requested. */ static bool sig_mask_changed; =20 +/* Whether to list non default handling. */ +static bool report_signal_handling; + static char const shortopts[] =3D "+C:ipS:u:v0 \t"; =20 /* For long options that have no equivalent short option, use a @@ -80,8 +83,7 @@ enum IGNORE_SIGNAL_OPTION, BLOCK_SIGNAL_OPTION, UNBLOCK_SIGNAL_OPTION, - LIST_BLOCKED_SIGNALS_OPTION, - LIST_IGNORED_SIGNALS_OPTION, + LIST_SIGNAL_HANDLING_OPTION, }; =20 static struct option const longopts[] =3D @@ -94,8 +96,7 @@ static struct option const longopts[] =3D {"ignore-signal", optional_argument, NULL, IGNORE_SIGNAL_OPTION}, {"block-signal", optional_argument, NULL, BLOCK_SIGNAL_OPTION}, {"unblock-signal", optional_argument, NULL, UNBLOCK_SIGNAL_OPTION}, - {"list-blocked-signals", no_argument, NULL, LIST_BLOCKED_SIGNALS_OPTIO= N}, - {"list-ignored-signals", no_argument, NULL, LIST_IGNORED_SIGNALS_OPTI= ON}, + {"list-signal-handling", no_argument, NULL, LIST_SIGNAL_HANDLING_OPTI= ON}, {"debug", no_argument, NULL, 'v'}, {"split-string", required_argument, NULL, 'S'}, {GETOPT_HELP_OPTION_DECL}, @@ -144,10 +145,7 @@ Set each NAME to VALUE in the environment and run CO= MMAND.\n\ --ignore-signal[=3DSIG] set handling of SIG signals(s) to do not= hing\n\ "), stdout); fputs (_("\ - --list-ignored-signals list ignored signals and exit\n\ -"), stdout); - fputs (_("\ - --list-blocked-signals list blocked (masked) signals and exit\n\ + --list-signal-handling list non default signal handling to stderr= \n\ "), stdout); fputs (_("\ -v, --debug print verbose information for each processing ste= p\n\ @@ -762,7 +760,7 @@ set_signal_proc_mask (void) } =20 static void -list_blocked_signals (void) +list_signal_handling (void) { sigset_t set; char signame[SIG2STR_MAX]; @@ -773,35 +771,21 @@ list_blocked_signals (void) =20 for (int i =3D 1; i <=3D SIGNUM_BOUND; i++) { - if (!sigismember (&set, i)) - continue; - - sig2str (i, signame); - printf ("%-10s (%2d)\n", signame, i); - } - - exit (EXIT_SUCCESS); -} - -static void -list_ignored_signals (void) -{ - char signame[SIG2STR_MAX]; - - for (int i =3D 1; i <=3D SIGNUM_BOUND; i++) - { struct sigaction act; if (sigaction (i, NULL, &act)) continue; =20 - if (act.sa_handler !=3D SIG_IGN) + char const* ignored =3D act.sa_handler =3D=3D SIG_IGN ? "IGNORE" := ""; + char const* blocked =3D sigismember (&set, i) ? "BLOCK" : ""; + char const* connect =3D *ignored && *blocked ? "," : ""; + + if (! *ignored && ! *blocked) continue; =20 sig2str (i, signame); - printf ("%-10s (%2d)\n", signame, i); + fprintf (stderr, "%-10s (%2d): %s%s%s\n", signame, i, + blocked, connect, ignored); } - - exit (EXIT_SUCCESS); } =20 int @@ -849,11 +833,8 @@ main (int argc, char **argv) case UNBLOCK_SIGNAL_OPTION: parse_block_signal_params (optarg, false); break; - case LIST_BLOCKED_SIGNALS_OPTION: - list_blocked_signals (); - break; - case LIST_IGNORED_SIGNALS_OPTION: - list_ignored_signals (); + case LIST_SIGNAL_HANDLING_OPTION: + report_signal_handling =3D true; break; case 'C': newdir =3D optarg; @@ -934,6 +915,9 @@ main (int argc, char **argv) if (sig_mask_changed) set_signal_proc_mask (); =20 + if (report_signal_handling) + list_signal_handling (); + if (newdir) { devmsg ("chdir: %s\n", quoteaf (newdir)); --=20 2.9.3 --------------BDFE3F77B504826D522D4A62-- From unknown Sun Jun 15 01:09:57 2025 X-Loop: help-debbugs@gnu.org Subject: bug#34488: Add sort --limit, or document workarounds for sort|head error messages Resent-From: =?UTF-8?Q?P=C3=A1draig?= Brady Original-Sender: "Debbugs-submit" Resent-CC: bug-coreutils@gnu.org Resent-Date: Mon, 04 Mar 2019 01:48:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 34488 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: To: Assaf Gordon Cc: 34488@debbugs.gnu.org Received: via spool by 34488-submit@debbugs.gnu.org id=B34488.155166405126723 (code B ref 34488); Mon, 04 Mar 2019 01:48:01 +0000 Received: (at 34488) by debbugs.gnu.org; 4 Mar 2019 01:47:31 +0000 Received: from localhost ([127.0.0.1]:58829 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1h0chX-0006wx-40 for submit@debbugs.gnu.org; Sun, 03 Mar 2019 20:47:31 -0500 Received: from mail.magicbluesmoke.com ([82.195.144.49]:39068) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1h0chU-0006wk-GA for 34488@debbugs.gnu.org; Sun, 03 Mar 2019 20:47:29 -0500 Received: from localhost.localdomain (unknown [76.21.115.186]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.magicbluesmoke.com (Postfix) with ESMTPSA id 9010EAA6E; Mon, 4 Mar 2019 01:47:26 +0000 (GMT) References: <87mumxf6xn.fsf@jidanni.org> <49916778-4758-d040-5fcc-6e277a2dc183@redhat.com> <5b729a22-c3fa-b2b8-f204-ef27ed3a7292@gmail.com> <17f89f02-d446-d964-ffd4-2aae65b411a9@gmail.com> <2d93c9af-d335-21b4-77c2-071532e32c66@cs.ucla.edu> <5b099892-8773-2794-b8f3-437c79a65a5f@gmail.com> <73fbf04f-c237-6a5a-584d-8152cc079f09@cs.ucla.edu> <514735cd-d8de-7f5d-f588-3c15856f1cdc@draigBrady.com> <683b367c-2b3b-1869-af8c-40d5a77370c3@gmail.com> <97dbf933-4bf9-0350-21c4-c4fc87ea788a@cs.ucla.edu> <20151538-6173-bb98-f719-325a8b1724d6@gmail.com> <1553a086-b917-bd6f-0ed4-713eb27ebc36@draigBrady.com> <1be1da7d-89c9-a270-1c44-92940feb270b@draigBrady.com> <5933d27b-93d6-66dc-cbad-ae2f61e19aa2@draigBrady.com> From: =?UTF-8?Q?P=C3=A1draig?= Brady Message-ID: Date: Sun, 3 Mar 2019 17:47:24 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/mixed; boundary="------------EB03A37F07D5C37B9B951637" X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) This is a multi-part message in MIME format. --------------EB03A37F07D5C37B9B951637 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit On 03/03/19 16:59, Pádraig Brady wrote: > A summary of the all signal options in my local set now is: > > --block-signal[=SIG] block delivery of SIG signal(s) to COMMAND > --unblock-signal[=SIG] unblock delivery of SIG signal(s) to COMMAND > --default-signal[=SIG] reset handling of SIG signal(s) to the default > --ignore-signal[=SIG] set handling of SIG signals(s) to do nothing > --list-signal-handling list non default signal handling to stderr I think we might be also able to remove --unblock-signal, and just have --default-signal. I.E. I don't think one would want to set default signal handling, but leave a signal blocked? Also I don't think one would want to unblock a signal, but leave it ignored? At least not and the level of env just exec()ing a program. Anyway if those weird cases are needed, they can be achieved by combining the options. The attached does that, leaving us with: --block-signal[=SIG] block delivery of SIG signal(s) to COMMAND --default-signal[=SIG] reset handling of SIG signal(s) to the default --ignore-signal[=SIG] set handling of SIG signals(s) to do nothing --list-signal-handling list non default signal handling to stderr cheers, Pádraig. --------------EB03A37F07D5C37B9B951637 Content-Type: text/x-patch; name="env-no-unblock.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="env-no-unblock.patch" =46rom 7183477b7a5d9531a43b48beee8906ea7ae6fc06 Mon Sep 17 00:00:00 2001 From: =3D?UTF-8?q?P=3DC3=3DA1draig=3D20Brady?=3D Date: Sun, 3 Mar 2019 17:40:34 -0800 Subject: [PATCH] env: have --default-signal imply --unblock-signal Remove --unblock as i's not needed in isolation --- doc/coreutils.texi | 12 +++++------- src/env.c | 9 +-------- 2 files changed, 6 insertions(+), 15 deletions(-) diff --git a/doc/coreutils.texi b/doc/coreutils.texi index 0e4ed16..8112034 100644 --- a/doc/coreutils.texi +++ b/doc/coreutils.texi @@ -17247,10 +17247,11 @@ env --chdir=3D/build FOO=3Dbar timeout 5 true @end example =20 @item --default-signal[=3D@var{sig}] -Reset signal @var{sig} to its default signal handler. Without @var{sig} = all -known signals are reset to their defaults. Multiple signals can be -comma-separated. The following command runs @command{seq} with SIGINT an= d -SIGPIPE set to their default (which is to terminate the program): +Unblock and reset signal @var{sig} to its default signal handler. +Without @var{sig} all known signals are reset to their defaults. +Multiple signals can be comma-separated. The following command runs +@command{seq} with SIGINT and SIGPIPE set to their default +(which is to terminate the program): =20 @example env --default-signal=3DPIPE,INT seq 1000 | head -n1 @@ -17302,9 +17303,6 @@ env --default-signal=3DINT,PIPE --ignore-signal=3D= INT @item --block-signal[=3D@var{sig}] Block signal(s) @var{sig} from being delivered. =20 -@item --unblock-signal[=3D@var{sig}] -Unblock signal(s) @var{sig}. - @item --list-blocked-signals List blocked (masked) signals and exit. If no signals are blocked, nothing is printed. diff --git a/src/env.c b/src/env.c index 9a910da..aa0cfbc 100644 --- a/src/env.c +++ b/src/env.c @@ -82,7 +82,6 @@ enum DEFAULT_SIGNAL_OPTION =3D CHAR_MAX + 1, IGNORE_SIGNAL_OPTION, BLOCK_SIGNAL_OPTION, - UNBLOCK_SIGNAL_OPTION, LIST_SIGNAL_HANDLING_OPTION, }; =20 @@ -95,7 +94,6 @@ static struct option const longopts[] =3D {"default-signal", optional_argument, NULL, DEFAULT_SIGNAL_OPTION}, {"ignore-signal", optional_argument, NULL, IGNORE_SIGNAL_OPTION}, {"block-signal", optional_argument, NULL, BLOCK_SIGNAL_OPTION}, - {"unblock-signal", optional_argument, NULL, UNBLOCK_SIGNAL_OPTION}, {"list-signal-handling", no_argument, NULL, LIST_SIGNAL_HANDLING_OPTI= ON}, {"debug", no_argument, NULL, 'v'}, {"split-string", required_argument, NULL, 'S'}, @@ -136,9 +134,6 @@ Set each NAME to VALUE in the environment and run COM= MAND.\n\ --block-signal[=3DSIG] block delivery of SIG signal(s) to COMMA= ND\n\ "), stdout); fputs (_("\ - --unblock-signal[=3DSIG] unblock delivery of SIG signal(s) to COM= MAND\n\ -"), stdout); - fputs (_("\ --default-signal[=3DSIG] reset handling of SIG signal(s) to the d= efault\n\ "), stdout); fputs (_("\ @@ -823,6 +818,7 @@ main (int argc, char **argv) break; case DEFAULT_SIGNAL_OPTION: parse_signal_action_params (optarg, true); + parse_block_signal_params (optarg, false); break; case IGNORE_SIGNAL_OPTION: parse_signal_action_params (optarg, false); @@ -830,9 +826,6 @@ main (int argc, char **argv) case BLOCK_SIGNAL_OPTION: parse_block_signal_params (optarg, true); break; - case UNBLOCK_SIGNAL_OPTION: - parse_block_signal_params (optarg, false); - break; case LIST_SIGNAL_HANDLING_OPTION: report_signal_handling =3D true; break; --=20 2.9.3 --------------EB03A37F07D5C37B9B951637-- From unknown Sun Jun 15 01:09:57 2025 X-Loop: help-debbugs@gnu.org Subject: bug#34488: Add sort --limit, or document workarounds for sort|head error messages Resent-From: Assaf Gordon Original-Sender: "Debbugs-submit" Resent-CC: bug-coreutils@gnu.org Resent-Date: Thu, 28 Mar 2019 18:34:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 34488 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: To: =?UTF-8?Q?P=C3=A1draig?= Brady , =?UTF-8?Q?=E7=A9=8D=E4=B8=B9=E5=B0=BC?= Dan Jacobson Cc: 34488@debbugs.gnu.org Received: via spool by 34488-submit@debbugs.gnu.org id=B34488.15537980145106 (code B ref 34488); Thu, 28 Mar 2019 18:34:01 +0000 Received: (at 34488) by debbugs.gnu.org; 28 Mar 2019 18:33:34 +0000 Received: from localhost ([127.0.0.1]:34719 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1h9ZqI-0001KD-Im for submit@debbugs.gnu.org; Thu, 28 Mar 2019 14:33:34 -0400 Received: from mail-pg1-f179.google.com ([209.85.215.179]:44622) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1h9ZqG-0001Jt-Mc; Thu, 28 Mar 2019 14:33:33 -0400 Received: by mail-pg1-f179.google.com with SMTP id i2so11995135pgj.11; Thu, 28 Mar 2019 11:33:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=3gp+zS49oz9zaWxJ7uoxrusropy4VU5v/XHUXObqcr8=; b=Bm1L8NqCKJ5Re3MeALZ982JASS74KsrNDt+tk+vH4J3aIKtaH6mLXvf0z9cWrUpBPL rn1CFTGFjC81BllTlMTmI5eGeTD+SuRT1bwiX0+i8gj+BYn/aVM4aLSojT2U9NglzKaz iq+T2ahqMValmWez95Fl0qR9yp/9jeP1Ix1KpN+N0ilKthLecsMJiLiIAwAhUilwEpoh A0tSId1Q6QKKc/xRqKGbSoLJNkSsDfvm6gdo3Kik4oj00zOLnUIf4Q/NmgLhl+CJqUGv Re/iPORJczOKXkMHz78TVX3WBQnXYn+ep6NJQslZFVVye7WH+PCt0XoP5atc7ySr3lKW 2RZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=3gp+zS49oz9zaWxJ7uoxrusropy4VU5v/XHUXObqcr8=; b=n6o6w4Qx9WPWQCqEQDFBGnCxtH7rZ+uRkfcHBRfiWlHeyso5Pdifxuzq3qFsWbG0WW Hm/hVtYBT2wzOuXGhLZ2pS2INwIHAteCZ72PqWx14/ZuZYFCDT2WyxfTICRqpLRDYabK cRJ8ICdjswRAYHBnGlXne2MYkxqI4zt4k+Qmkv5Zj2s8u1B/iSvWWdX4sd6L/pMP0ZYa xHk3f4ZmBy1Wc1QKFzXMzeNm8TA7YkKePrOnCwGoWJEkWxM9zT23b/5z/OjRfSicO44x zRm9fX6LAGFd74W2LkOYbRtVGesROWXDCXPBTU+Gw7PcdeWoXfNbxqWI5iMXwU8UHJnU mG7Q== X-Gm-Message-State: APjAAAXdcRKfn+GESjqGQ/caOSdK0CJrPPryDa10q2NjfTYluKtR2ffg Y8VQYEbbaWSZbZ2eXufBS1b9sgz1WK0= X-Google-Smtp-Source: APXvYqzt5kVHOxV1XWgFAhPiL9eMHy3y/v/GBvYAISPXVTIsRaAaEVvtrERbTkwRK/DkgCUrbCk3Og== X-Received: by 2002:a62:e315:: with SMTP id g21mr41642033pfh.2.1553798006248; Thu, 28 Mar 2019 11:33:26 -0700 (PDT) Received: from tomato.housegordon.com (moose.housegordon.com. [184.68.105.38]) by smtp.googlemail.com with ESMTPSA id g64sm56968464pfg.13.2019.03.28.11.33.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 Mar 2019 11:33:24 -0700 (PDT) References: <87mumxf6xn.fsf@jidanni.org> <49916778-4758-d040-5fcc-6e277a2dc183@redhat.com> <5b729a22-c3fa-b2b8-f204-ef27ed3a7292@gmail.com> <17f89f02-d446-d964-ffd4-2aae65b411a9@gmail.com> <2d93c9af-d335-21b4-77c2-071532e32c66@cs.ucla.edu> <5b099892-8773-2794-b8f3-437c79a65a5f@gmail.com> <73fbf04f-c237-6a5a-584d-8152cc079f09@cs.ucla.edu> <514735cd-d8de-7f5d-f588-3c15856f1cdc@draigBrady.com> <683b367c-2b3b-1869-af8c-40d5a77370c3@gmail.com> <97dbf933-4bf9-0350-21c4-c4fc87ea788a@cs.ucla.edu> <20151538-6173-bb98-f719-325a8b1724d6@gmail.com> <1553a086-b917-bd6f-0ed4-713eb27ebc36@draigBrady.com> <1be1da7d-89c9-a270-1c44-92940feb270b@draigBrady.com> <5933d27b-93d6-66dc-cbad-ae2f61e19aa2@draigBrady.com> From: Assaf Gordon Message-ID: <78fcfc00-0d04-1c39-4a99-bc5f4edac62c@gmail.com> Date: Thu, 28 Mar 2019 12:33:23 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.5.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) tags 34488 fixed close 34488 stop Hello, The original request of "sort --limit" resulted in an improved "env" with options new options, which was included in the recent version 8.31. I'm therefor closing this item. -assaf