From mboxrd@z Thu Jan 1 00:00:00 1970 From: Mark H Weaver Subject: bug#29826: nondeterministic Broken pipe Date: Sun, 24 Dec 2017 17:11:48 -0500 Message-ID: <87d133lqsb.fsf@netris.org> References: <874lohdwhb.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:44940) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eTEW3-0008I9-Ri for bug-guix@gnu.org; Sun, 24 Dec 2017 17:13:08 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eTEVy-0005on-QD for bug-guix@gnu.org; Sun, 24 Dec 2017 17:13:07 -0500 Received: from debbugs.gnu.org ([208.118.235.43]:42323) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eTEVy-0005ob-Lt for bug-guix@gnu.org; Sun, 24 Dec 2017 17:13:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1eTEVy-00028Z-GJ for bug-guix@gnu.org; Sun, 24 Dec 2017 17:13:02 -0500 Sender: "Debbugs-submit" Resent-Message-ID: In-Reply-To: <874lohdwhb.fsf@gmail.com> (Alex Vong's message of "Sun, 24 Dec 2017 04:23:44 +0800") 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: Alex Vong Cc: 29826@debbugs.gnu.org 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, the > 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