From mboxrd@z Thu Jan 1 00:00:00 1970 From: Alex Vong Subject: bug#29826: nondeterministic Broken pipe Date: Tue, 02 Jan 2018 20:07:41 +0800 Message-ID: <87po6s31ma.fsf@gmail.com> References: <874lohdwhb.fsf@gmail.com> <87d133lqsb.fsf@netris.org> <87608uaorx.fsf@gmail.com> <87k1x32on0.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:52460) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eWLNU-00072t-G2 for bug-guix@gnu.org; Tue, 02 Jan 2018 07:09:09 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eWLNP-0003DF-Bo for bug-guix@gnu.org; Tue, 02 Jan 2018 07:09:08 -0500 Received: from debbugs.gnu.org ([208.118.235.43]:51871) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eWLNP-0003D3-87 for bug-guix@gnu.org; Tue, 02 Jan 2018 07:09:03 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1eWLNO-0001fM-6l for bug-guix@gnu.org; Tue, 02 Jan 2018 07:09:02 -0500 Sender: "Debbugs-submit" Resent-Message-ID: In-Reply-To: <87k1x32on0.fsf@gnu.org> ("Ludovic \=\?utf-8\?Q\?Court\=C3\=A8s\=22'\?\= \=\?utf-8\?Q\?s\?\= message of "Sun, 31 Dec 2017 11:11:15 +0100") List-Id: Bug reports for GNU Guix List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guix-bounces+gcggb-bug-guix=m.gmane.org@gnu.org Sender: "bug-Guix" To: Ludovic =?UTF-8?Q?Court=C3=A8s?= Cc: 29826@debbugs.gnu.org --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hello, ludo@gnu.org (Ludovic Court=C3=A8s) writes: > Hi, > > Alex Vong skribis: > >> Mark H Weaver writes: >> >>> Alex Vong writes: >>> >>>> I get the following error when running ``guix --version | head -n 1''.= I >>>> can get similar after replacing ``--version'' with ``--help''. Also, t= he >>>> error is nondeterministic. Any idea? >>> >>> Attempts to write to a pipe that has already been closed on the other >>> end results in EPIPE. From the write(2) man page: >>> >>> EPIPE fd is connected to a pipe or socket whose reading end is closed. >>> When this happens the writing process will also receive a >>> SIGPIPE signal. (Thus, the write return value is seen only if >>> the program catches, blocks or ignores this signal.) >>> >>> In this case, there's a race condition. The result depends on whether >>> "head -n 1" closes its end of the pipe before or after "guix --version" >>> is finished writing all of its output. If "head -n 1" closes the pipe >>> first, then "guix --version" will receive EPIPE while attempting to >>> write to it. >>> >>> What normally happens is that the sending process receives SIGPIPE, >>> which simply causes it to exit prematurely without ever receiving this >>> error. However, since Guix arranges to ignore SIGPIPE in >>> 'initialize-guix' in guix/ui.scm, we receive EPIPE. >>> >>> That's what's happening here. I'll need to think on how best to fix it. >>> >>> Regards, >>> Mark >> >> Nice explaination as always! I forget to mention that I reported a bug >> of similar flavour before . I agree that >> thought is needed to fix all instances of this type of bug. > > Not sure! We specifically ignore EPIPE in cases where it matters, such > as for the output of =E2=80=98guix package --search=E2=80=99, =E2=80=98gu= ix package -A=E2=80=99, etc. > In other cases, it=E2=80=99s probably an error, so it=E2=80=99s worth rep= orting. > > WDYT? > > In C such errors are usually ignored, which is nice for shell hackery > but otherwise not so great. > > Ludo=E2=80=99. Do you mean there are use-cases where the EPIPE signal really means there is an error? What I think is that the 'guix' command is meant to be used in a shell script, so it should work nice with other shell tools in a pipe, including head & tail. But maybe it will cause other problems if we always ignore EPIPE, I don't know...=20 --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEdZDkzSn0Cycogr9IxYq4eRf1Ea4FAlpLdg4ACgkQxYq4eRf1 Ea7vRw/7BGm0Jbf9jIVP4Uham/SKiMXmo2jRjRpXCeYcafNjP/Z1L0Mo7tPgC3nv /vZK8L8WkIRkeGfhjYUrkXIkrBXR96KAtNshnMHiqsVfeWsXtvUbB8lS8XCIk+rm fLgwtrUNZZNdNxGbnY1wfr6nkE/Ziq4FWNOr8ww+fUIWVK0jLtWDoTbm/7SYaupd mTUgfyH58yjhZCTCBlRutKxCyQZotubyMhI2KStlL0F0QwE4AuvVFvSQqevgrhon Emec7X896X+NIh9rLAJW6D9GbmzMYqLdriUmKKFDL8bldZgYAN1ikZXJkOboSQUz 2lEHcAHBSXobzvxd6u8bqV15FcpY8vkZTR0F5DO11VKWcErOnSo6Kr8+MXNDDQTb Ii5YIY+etUcc/M6CSegcwJn89lw6XbkxY9OoyhkTf8WaDB+d8ve+U1pYRKwEolo2 mTfnv+mJ3sVb+l4KRZrrITBA/pAsKn94L+tH3wYQiIYZmvpNPiiZdqESf3DwUijR ql9I6C6IJcaHXrVRQCgQvq/uCVPWAlyxVi42NIQ3OZYdFHe7EUbjhmQH7FLf417T OUuEeg5IRJteSSBaGedox9ZQ6JvTEqSmc9pXP4p6HAJlGC01oA0KaBSgJ3Mt2fKx o46YFYZ+XCb8NAvSebtxZJ1/H/ct1S2VuFFJS1ki3GFmRZPP1Vw= =JkIe -----END PGP SIGNATURE----- --=-=-=--