From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id qHaCCemauWL9WwAAbAwnHQ (envelope-from ) for ; Mon, 27 Jun 2022 13:56:25 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id 4Ig4CemauWK96AAAauVa8A (envelope-from ) for ; Mon, 27 Jun 2022 13:56:25 +0200 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id AB50844FC3 for ; Mon, 27 Jun 2022 13:56:24 +0200 (CEST) Received: from localhost ([::1]:58082 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o5nLr-0003io-LE for larch@yhetil.org; Mon, 27 Jun 2022 07:56:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35296) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o5nLW-0003iP-AC for guix-patches@gnu.org; Mon, 27 Jun 2022 07:56:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:56202) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o5nLW-0006EH-1y for guix-patches@gnu.org; Mon, 27 Jun 2022 07:56:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1o5nLW-0002LH-1l for guix-patches@gnu.org; Mon, 27 Jun 2022 07:56:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#56218] [PATCH] guix: inferior: Fix the behaviour of open-inferior #:error-port. Resent-From: Christopher Baines Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Mon, 27 Jun 2022 11:56:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 56218 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Ludovic =?UTF-8?Q?Court=C3=A8s?= Cc: 56218@debbugs.gnu.org Received: via spool by 56218-submit@debbugs.gnu.org id=B56218.16563309218946 (code B ref 56218); Mon, 27 Jun 2022 11:56:02 +0000 Received: (at 56218) by debbugs.gnu.org; 27 Jun 2022 11:55:21 +0000 Received: from localhost ([127.0.0.1]:50099 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1o5nKr-0002KB-6z for submit@debbugs.gnu.org; Mon, 27 Jun 2022 07:55:21 -0400 Received: from mira.cbaines.net ([212.71.252.8]:41340) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1o5nKp-0002K2-0e for 56218@debbugs.gnu.org; Mon, 27 Jun 2022 07:55:19 -0400 Received: from localhost (unknown [IPv6:2a02:8010:68c1:0:54d1:d5d4:280e:f699]) by mira.cbaines.net (Postfix) with ESMTPSA id F297A27BBE9; Mon, 27 Jun 2022 12:55:17 +0100 (BST) Received: from felis (localhost [127.0.0.1]) by localhost (OpenSMTPD) with ESMTP id b124bcb0; Mon, 27 Jun 2022 11:55:17 +0000 (UTC) References: <20220625171847.29104-1-mail@cbaines.net> <87v8snqvf2.fsf@gnu.org> User-agent: mu4e 1.6.10; emacs 28.1 From: Christopher Baines Date: Mon, 27 Jun 2022 12:39:55 +0100 In-reply-to: <87v8snqvf2.fsf@gnu.org> Message-ID: <87fsjql3rw.fsf@cbaines.net> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: "Guix-patches" X-Migadu-Flow: FLOW_IN X-Migadu-To: larch@yhetil.org X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1656330984; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:resent-cc:resent-from:resent-sender: resent-message-id:in-reply-to:in-reply-to:references:references: list-id:list-help:list-unsubscribe:list-subscribe:list-post; bh=qsMIgs09Z/c3HebjwRJsXtVFCsZt6LEH+sx8QO+a/qw=; b=H8RFtSKXeiOQqA4jO25Gg5KFn6sYhv3laADTq8xbYxADQF9WaCFdcbdLqUzUVt91vyryET vqw2kjTSbiz+a2z7BoZgwDaFQm8HXirHU44ZMhAuYED4WVDJEXcUTM0A4H//4/tmvEuRdp Kv7dqzPOSr/fMGzoqkwsnbq+Vo8ydHuyPrXYKJ88KmrGCjH/VwGjRONjIkUz8q8/Nyk1St cGA3vsx2AlMfwhZlHflyhRUxbfmCIhKvSuEwn1x2fZo9JP7cfA8m/wwIPxITfB2RWGL2cb 1XVVt2pbAC/BLkHHE3mZ9QgT2I8NoYVitfabei8o/jBzttv5TmPegcdetkImtg== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1656330984; a=rsa-sha256; cv=none; b=gXwmlbwBWSgB3KI/rP5N0RDsJN3fG89QgNftLdvTdk4KjACNWXSuVjfhkmf7RYelMQQRze Dw9q1J7AlpLxtLbK59gmwg4/We0XFFNEQc0pXBWZVXSuczNq6CYRQ2ng+tjtavopaQdW+v B0heS1gUB/6pVICIzbumfVku/JslOjMr8q83t7zw0E26LxwgsH15R/tj0jERtVxuI9xuoB 5DIf3yjUEbdnI+4oGA/cUFKUnhF+i3MIjg8fervrHj14WQEQiHVTNyCcS5IvEvcc8VPJ2/ ZAMHheG9Q0CE96H+49p65btunqzB369Nu1a0nzgN0EBJtvtkihe/EcW2dUq6Lw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: -5.55 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: AB50844FC3 X-Spam-Score: -5.55 X-Migadu-Scanner: scn0.migadu.com X-TUID: 7O3rroQwTNPF --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Ludovic Court=C3=A8s writes: > Hi Christopher, > > Christopher Baines skribis: > >> This should be the error port used by the inferior process, but currentl= y it's >> either stderr if #:error-port is a file port, or /dev/null otherwise. > > That=E2=80=99s still the case with this patch, no? > > The patch does make a difference when (current-error-port) wraps a file > descriptor other than 2 though. Maybe this sentance is a little unclear. What I'm trying to say is that passing a port as #:error-port doesn't really work. There's no scenario where the output actually goes to the port you provide, though it can have some effect. >> +++ b/guix/inferior.scm >> @@ -156,12 +156,14 @@ (define (open-bidirectional-pipe command . args) >> (close-port parent) >> (close-fdes 0) >> (close-fdes 1) >> + (close-fdes 2) >> (dup2 (fileno child) 0) >> (dup2 (fileno child) 1) >> ;; Mimic 'open-pipe*'. >> - (unless (file-port? (current-error-port)) >> - (close-fdes 2) >> - (dup2 (open-fdes "/dev/null" O_WRONLY) 2)) >> + (dup2 (if (file-port? (current-error-port)) >> + (fileno (current-error-port)) >> + (open-fdes "/dev/null" O_WRONLY)) >> + 2) > > If (current-error-port) wraps FD 2 when the function is called, then, by > the time we reach (dup2 =E2=80=A6 2), the FD behind (current-error-port) = has be > closed; we end up doing (dup2 2 2), but FD 2 is closed, so we get EBADF. > > Or am I misunderstanding? That sounds reasonable, I've only tested this change in the scenario when the #:error-port isn't stderr, and I mostly adapted this from what I thought open-pipe* did. Maxime suggested using move->fdes, so maybe this would be an improved version: ;; Mimic 'open-pipe*'. (if (file-port? (current-error-port)) (unless (eq? (fileno (current-error-port)) 2) (move-fdes (current-error-port) 2)) (move->fdes (open-file "/dev/null" O_WRONLY) 2)) > Perhaps we should add one test for each case (error port is a file port > vs. error port is another kind of port) in =E2=80=98tests/inferior.scm=E2= =80=99. Yep, sounds good. Thanks, Chris --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQKlBAEBCgCPFiEEPonu50WOcg2XVOCyXiijOwuE9XcFAmK5mqNfFIAAAAAALgAo aXNzdWVyLWZwckBub3RhdGlvbnMub3BlbnBncC5maWZ0aGhvcnNlbWFuLm5ldDNF ODlFRUU3NDU4RTcyMEQ5NzU0RTBCMjVFMjhBMzNCMEI4NEY1NzcRHG1haWxAY2Jh aW5lcy5uZXQACgkQXiijOwuE9XchPQ//YAAcZAUwEHAHb8NWWU91G1cr1xgacXfP mLwyCr3kREI8yd3JBfuj84bR2NRMz5ddvxC/pveR7hh/91hEvpR7n0RTkFXO9P7i B15qLNJ87QDraX4AS0qMvhY7adbNRD7U7fzK4jXY7uqUln4SEdd9IppW+EivIipy 3YQVbSNl6YCWT2Ap+LPIowXl5r3WHhVGSQKApqIC2IqHmmgW/4VTiO3GClRqlIBl nrG4buaQMCj/EOaki03bckqh6KPSeoGwCyRDCcqPjrfBDg3nOhOHZSsBt0Mooktq +mc2Icy6Ibmibu9c2hckwioc17v2TvuHUcOWYD6w9Mbhmmx4fc9EbxXHMxx7wEnK MeWaWwYQwGvYT1KRMbEa8XbFJjBf0Ugyogu1c2WJohYds2n8yYqmbr10dJhCw/m7 rRcB0CI7MkeQgk2lVzMKFb4+6GmwY4PLCTOju7UcszsWwE2ubZ9BGLScUSstBZl1 78aM5giS3M7TrwIJj81rMeIvVPCdiFuF0fNfwdJWcS1pZQLyE0akfyvqqtzyKJTM sf1IWetVbErUcBfzGZEdkqmBOU6aSSr6esed+CuQDxTDCH5CxO4Q984p/DT83jVA H7dsOViglcMuE9B4h3Gl57+DAp/iRFZusQrfsVJtX75HdHjioP7nV3hnhrRq4BU0 ijd1psGfW3M= =x3+O -----END PGP SIGNATURE----- --=-=-=--