From unknown Sat Jun 21 03:18:54 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#56218 <56218@debbugs.gnu.org> To: bug#56218 <56218@debbugs.gnu.org> Subject: Status: [PATCH] guix: inferior: Fix the behaviour of open-inferior #:error-port. Reply-To: bug#56218 <56218@debbugs.gnu.org> Date: Sat, 21 Jun 2025 10:18:54 +0000 retitle 56218 [PATCH] guix: inferior: Fix the behaviour of open-inferior #:= error-port. reassign 56218 guix-patches submitter 56218 Christopher Baines severity 56218 normal tag 56218 patch thanks From debbugs-submit-bounces@debbugs.gnu.org Sat Jun 25 13:18:54 2022 Received: (at submit) by debbugs.gnu.org; 25 Jun 2022 17:18:54 +0000 Received: from localhost ([127.0.0.1]:46155 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1o59Qs-0006lv-By for submit@debbugs.gnu.org; Sat, 25 Jun 2022 13:18:54 -0400 Received: from lists.gnu.org ([209.51.188.17]:40238) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1o59Qp-0006ll-Va for submit@debbugs.gnu.org; Sat, 25 Jun 2022 13:18:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47384) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o59Qp-00010N-Q8 for guix-patches@gnu.org; Sat, 25 Jun 2022 13:18:51 -0400 Received: from mira.cbaines.net ([212.71.252.8]:36428) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o59Qo-00040D-84 for guix-patches@gnu.org; Sat, 25 Jun 2022 13:18:51 -0400 Received: from localhost (unknown [IPv6:2a02:8010:68c1:0:54d1:d5d4:280e:f699]) by mira.cbaines.net (Postfix) with ESMTPSA id ED17E27BBE9 for ; Sat, 25 Jun 2022 18:18:47 +0100 (BST) Received: from localhost (localhost [local]) by localhost (OpenSMTPD) with ESMTPA id 1fba1de2 for ; Sat, 25 Jun 2022 17:18:47 +0000 (UTC) From: Christopher Baines To: guix-patches@gnu.org Subject: [PATCH] guix: inferior: Fix the behaviour of open-inferior #:error-port. Date: Sat, 25 Jun 2022 18:18:47 +0100 Message-Id: <20220625171847.29104-1-mail@cbaines.net> X-Mailer: git-send-email 2.36.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=212.71.252.8; envelope-from=mail@cbaines.net; helo=mira.cbaines.net X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01, UNPARSEABLE_RELAY=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.4 (-) X-Debbugs-Envelope-To: submit 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: -2.4 (--) This should be the error port used by the inferior process, but currently it's either stderr if #:error-port is a file port, or /dev/null otherwise. I'm looking at this as the Guix Data Service uses this behaviour to record and display logs from inferior processes. * guix/inferior.scm (open-bidirectional-pipe): Call dup2 for file descriptor 2, passing either the file number for the current error port, or a file descriptor for /dev/null. --- guix/inferior.scm | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/guix/inferior.scm b/guix/inferior.scm index 54200b75e4..e36806ac84 100644 --- a/guix/inferior.scm +++ 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) (apply execlp command command args)) (lambda () (primitive-_exit 127)))) -- 2.36.1 From debbugs-submit-bounces@debbugs.gnu.org Sat Jun 25 13:50:18 2022 Received: (at 56218) by debbugs.gnu.org; 25 Jun 2022 17:50:18 +0000 Received: from localhost ([127.0.0.1]:46185 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1o59vF-0007aG-O2 for submit@debbugs.gnu.org; Sat, 25 Jun 2022 13:50:17 -0400 Received: from andre.telenet-ops.be ([195.130.132.53]:45540) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1o59vC-0007a3-MD for 56218@debbugs.gnu.org; Sat, 25 Jun 2022 13:50:16 -0400 Received: from ptr-bvsjgyhxw7psv60dyze.18120a2.ip6.access.telenet.be ([IPv6:2a02:1811:8c09:9d00:3c5f:2eff:feb0:ba5a]) by andre.telenet-ops.be with bizsmtp id nVqC270064UW6Th01VqCbU; Sat, 25 Jun 2022 19:50:12 +0200 Message-ID: Subject: Re: [bug#56218] [PATCH] guix: inferior: Fix the behaviour of open-inferior #:error-port. From: Maxime Devos To: Christopher Baines , 56218@debbugs.gnu.org Date: Sat, 25 Jun 2022 19:50:12 +0200 In-Reply-To: <20220625171847.29104-1-mail@cbaines.net> References: <20220625171847.29104-1-mail@cbaines.net> Content-Type: multipart/signed; micalg="pgp-sha512"; protocol="application/pgp-signature"; boundary="=-Av9+b8oa5XXUSbXKwhF6" User-Agent: Evolution 3.38.3-1 MIME-Version: 1.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telenet.be; s=r22; t=1656179412; bh=CXaMTw+SkxJi5eaEFQhRkFvbdpSIrZh+PEuhHubcCwQ=; h=Subject:From:To:Date:In-Reply-To:References; b=nhVjCX+SIYHhFum7DasZNQETXuAbS9tBSR7kvx/4s/QoHyXlp4vsQ9faImskfyorf +eqRTN1WafhMizEP04DRaI3qPiYK+JQZrci+AZfFHKxD9J1GitiyzF59sNZkVJ8PFt VHXzutj7ibQgOgHjxYgdzgWqgLaIsGDjG0ea7MCDzVoTJqfdO9/KMCEV2nj7Qrym/+ JO4ztRGNiDa7iA/mYhEr5XrHghUOs5OljyZoabe7XXJYDFBamwDU4O0l7gO7qkJj2J FulJGiHYjLKQqPscWqrfMj8GJvjKcdn6oU55oGyJm6wSUcLW1Sb8N0sZANl5QWQCZU +i7oyr1qJBUmA== X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 56218 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 (-) --=-Av9+b8oa5XXUSbXKwhF6 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: base64 Q2hyaXN0b3BoZXIgQmFpbmVzIHNjaHJlZWYgb3AgemEgMjUtMDYtMjAyMiBvbSAxODoxOCBbKzAx MDBdOgo+IMKgwqDCoMKgwqDCoMKgwqDCoMKgwqDCoCAoY2xvc2UtcG9ydCBwYXJlbnQpCj4gwqDC oMKgwqDCoMKgwqDCoMKgwqDCoMKgIChjbG9zZS1mZGVzIDApCj4gwqDCoMKgwqDCoMKgwqDCoMKg wqDCoMKgIChjbG9zZS1mZGVzIDEpCj4gK8KgwqDCoMKgwqDCoMKgwqDCoMKgwqAgKGNsb3NlLWZk ZXMgMikKPiDCoMKgwqDCoMKgwqDCoMKgwqDCoMKgwqAgKGR1cDIgKGZpbGVubyBjaGlsZCkgMCkK PiDCoMKgwqDCoMKgwqDCoMKgwqDCoMKgwqAgKGR1cDIgKGZpbGVubyBjaGlsZCkgMSkKPiDCoMKg wqDCoMK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gICAo bW92ZS0+ZmRlcyAoY3VycmVudC1lcnJvci1wb3J0KSAyKQogICAgICAobW92ZS0+ZmRlcyAob3Bl bi1maWxlICIvZGV2L251bGwiIE9fV1JPTkxZKSAyKSkKCgooKik6IG1vdmUtPmZkZXMgYXV0b21h dGljYWxseSBtb3ZlcyBwb3J0cyBvdXQgb2YgdGhlIHdheS4gIEFsc28sIGlmIG9uZQpvZiB0aGUg bW92ZXMgZmFpbHMsIHRoZW4gYXQgbGVhc3QgKGN1cnJlbnQtb3V0cHV0LXBvcnQpIGV0YyB3aWxs IHN0aWxsCmhhdmUgYSBjb3JyZWN0IGZkIHNvIHNvbWUgZXJyb3IgcmVwb3J0aW5nIHNob3VsZCBi ZSBwb3NzaWJsZQoKR3JlZXRpbmdzLApNYXhpbWUuCg== --=-Av9+b8oa5XXUSbXKwhF6 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part Content-Transfer-Encoding: 7bit -----BEGIN PGP SIGNATURE----- iI0EABYKADUWIQTB8z7iDFKP233XAR9J4+4iGRcl7gUCYrdK1BccbWF4aW1lZGV2 b3NAdGVsZW5ldC5iZQAKCRBJ4+4iGRcl7sm6AP0a9A7nub6rSATS8jNEbox8gkMz 5fHUcI4z8wkxiR4KIAEAsi/pr7LCshHQxvVJLWPEOBG9ax7CHUcC5Mz09Hn4/w4= =fceQ -----END PGP SIGNATURE----- --=-Av9+b8oa5XXUSbXKwhF6-- From debbugs-submit-bounces@debbugs.gnu.org Sat Jun 25 16:59:47 2022 Received: (at 56218) by debbugs.gnu.org; 25 Jun 2022 20:59:47 +0000 Received: from localhost ([127.0.0.1]:46293 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1o5Csd-0003nU-AK for submit@debbugs.gnu.org; Sat, 25 Jun 2022 16:59:47 -0400 Received: from baptiste.telenet-ops.be ([195.130.132.51]:36862) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1o5Csb-0003nK-89 for 56218@debbugs.gnu.org; Sat, 25 Jun 2022 16:59:46 -0400 Received: from ptr-bvsjgyhxw7psv60dyze.18120a2.ip6.access.telenet.be ([IPv6:2a02:1811:8c09:9d00:3c5f:2eff:feb0:ba5a]) by baptiste.telenet-ops.be with bizsmtp id nYzi270084UW6Th01YziwU; Sat, 25 Jun 2022 22:59:43 +0200 Message-ID: <6d23e4d641e1273fb01bdc35a24050b6236a4d25.camel@telenet.be> Subject: Re: [bug#56218] [PATCH] guix: inferior: Fix the behaviour of open-inferior #:error-port. From: Maxime Devos To: Christopher Baines , 56218@debbugs.gnu.org Date: Sat, 25 Jun 2022 22:59:37 +0200 In-Reply-To: References: <20220625171847.29104-1-mail@cbaines.net> Content-Type: multipart/signed; micalg="pgp-sha512"; protocol="application/pgp-signature"; boundary="=-QGji9rLxbSawKAp7+JKl" User-Agent: Evolution 3.38.3-1 MIME-Version: 1.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telenet.be; s=r22; t=1656190783; bh=z/0c9s7zjCZJKo+XtGQoVVzOMEpQwFh7AuThGcgrrxA=; h=Subject:From:To:Date:In-Reply-To:References; b=NZBjBbCo4dP0sUJTa51tOxOyAHdDEIpt03p/mOXQIiTqpFpJoQCBc4JAOasURt+Ok 6ABZCikKxlcfsxbCpUG9HaEb+wRfl+g/fTIHZiMBMua0wFQysQ8wgKQMOJQK32Ujn1 l2t3bX3Tvqc3LBYCynKLsWIOPx8WKcevWIVeciuf137zNyRhL3mV9UpKThNFiDPZbm v9UTNa0eFDECMxHvYpk2UrBE4jvvYXmmOI6L++bVSkwNyurx8tHyW5Fj063GVmybqf vkjG10JhoG6AsxCY11CLIfwFeFiuVv9ZjFzEib/Yi9NFZEbkEIonVd0+mZD6WX9lER SVfuM6qAjapsA== X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 56218 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 (-) --=-QGji9rLxbSawKAp7+JKl Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Maxime Devos schreef op za 25-06-2022 om 19:50 [+0200]: > I don't this would work if (current-error-port) has fd 1. [...] TBC, I never worked with file descriptor manipulation and process forking much, and I didn't look at the surrounding code, so don't take my word for it. --=-QGji9rLxbSawKAp7+JKl Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part Content-Transfer-Encoding: 7bit -----BEGIN PGP SIGNATURE----- iI0EABYKADUWIQTB8z7iDFKP233XAR9J4+4iGRcl7gUCYrd3ORccbWF4aW1lZGV2 b3NAdGVsZW5ldC5iZQAKCRBJ4+4iGRcl7sUeAQD8fSsuoJcDeTxBJimIWuJfXyCH U2w4uuYLe8KfZ++FlwD/RKoOx0lWYRmil6MLA6WTFBp5WWabB2s9Q9rfvsVIdA8= =/9xV -----END PGP SIGNATURE----- --=-QGji9rLxbSawKAp7+JKl-- From debbugs-submit-bounces@debbugs.gnu.org Sun Jun 26 11:47:07 2022 Received: (at 56218) by debbugs.gnu.org; 26 Jun 2022 15:47:07 +0000 Received: from localhost ([127.0.0.1]:48765 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1o5UTb-0007XY-9U for submit@debbugs.gnu.org; Sun, 26 Jun 2022 11:47:07 -0400 Received: from eggs.gnu.org ([209.51.188.92]:37084) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1o5UTZ-0007Re-Fp for 56218@debbugs.gnu.org; Sun, 26 Jun 2022 11:47:05 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:50164) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o5UTU-0005cW-2b; Sun, 26 Jun 2022 11:47:00 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:In-Reply-To:Date:References:Subject:To: From; bh=BefgDQVHasrsLSEisg8hTNhLRRl50171Z11i0HCclTE=; b=iuoHj+d2Gn2BjVOHisNU 1qBSyuzhqiCBArYlwrjxvsf6uqCCU1PzfSBhNlmL9oPIWVg5em+RE3MtZwisASzH1VcnsE3qoM0To mfvF9R0ogtETaMT1aVMOKN/5z5q9Best1vJGT207EdSpem+BkrQuS+GNXiy4KAnA4ufVgH0aDeAhf HRTTXWWYmBHtWmj7hb/teYPw5nsO45aX72/2hde1HYXvTjfALNScoNP1mPIzOJ+fgWxGKxqYAFngg DG4bFnkzLyT7+C5z1RK/auCy7Ww/hpY6tR5tCSi43XlTdOZS4t5Cv0GyHyEjWdtFqwsPM/7fxJ5bb 6nRKu8KjXdnJ2g==; Received: from 91-160-117-201.subs.proxad.net ([91.160.117.201]:62793 helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o5UTT-0003LM-Je; Sun, 26 Jun 2022 11:46:59 -0400 From: =?utf-8?Q?Ludovic_Court=C3=A8s?= To: Christopher Baines Subject: Re: bug#56218: [PATCH] guix: inferior: Fix the behaviour of open-inferior #:error-port. References: <20220625171847.29104-1-mail@cbaines.net> Date: Sun, 26 Jun 2022 17:46:57 +0200 In-Reply-To: <20220625171847.29104-1-mail@cbaines.net> (Christopher Baines's message of "Sat, 25 Jun 2022 18:18:47 +0100") Message-ID: <87v8snqvf2.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 56218 Cc: 56218@debbugs.gnu.org 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 (---) Hi Christopher, Christopher Baines skribis: > This should be the error port used by the inferior process, but currently= 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. > +++ 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) ha= s be closed; we end up doing (dup2 2 2), but FD 2 is closed, so we get EBADF. Or am I misunderstanding? 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. Thanks, Ludo=E2=80=99. From debbugs-submit-bounces@debbugs.gnu.org Mon Jun 27 07:40:06 2022 Received: (at 56218) by debbugs.gnu.org; 27 Jun 2022 11:40:06 +0000 Received: from localhost ([127.0.0.1]:50070 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1o5n5x-0001qa-En for submit@debbugs.gnu.org; Mon, 27 Jun 2022 07:40:06 -0400 Received: from mira.cbaines.net ([212.71.252.8]:41338) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1o5n5t-0001qF-3T for 56218@debbugs.gnu.org; Mon, 27 Jun 2022 07:39:55 -0400 Received: from localhost (unknown [IPv6:2a02:8010:68c1:0:54d1:d5d4:280e:f699]) by mira.cbaines.net (Postfix) with ESMTPSA id DE59527BBE9; Mon, 27 Jun 2022 12:39:51 +0100 (BST) Received: from felis (localhost [127.0.0.1]) by localhost (OpenSMTPD) with ESMTP id 722e7adf; Mon, 27 Jun 2022 11:39:51 +0000 (UTC) References: <20220625171847.29104-1-mail@cbaines.net> User-agent: mu4e 1.6.10; emacs 28.1 From: Christopher Baines To: Maxime Devos Subject: Re: [bug#56218] [PATCH] guix: inferior: Fix the behaviour of open-inferior #:error-port. Date: Mon, 27 Jun 2022 12:37:58 +0100 In-reply-to: Message-ID: <87k092l4hn.fsf@cbaines.net> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 56218 Cc: 56218@debbugs.gnu.org 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 (-) --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: base64 DQpNYXhpbWUgRGV2b3MgPG1heGltZWRldm9zQHRlbGVuZXQuYmU+IHdyaXRlczoNCg0KPiBbW1BH UCBTaWduZWQgUGFydDpVbmRlY2lkZWRdXQ0KPiBDaHJpc3RvcGhlciBCYWluZXMgc2NocmVlZiBv cCB6YSAyNS0wNi0yMDIyIG9tIDE4OjE4IFsrMDEwMF06DQo+PiDCoMKgwqDCoMKgwqDCoMKgwqDC oMKgwqAgKGNsb3NlLXBvcnQgcGFyZW50KQ0KPj4gwqDCoMKgwqDCoMKgwqDCoMKgwqDCoMKgIChj bG9zZS1mZGVzIDApDQo+PiDCoMKgwqDCoMKgwqDCoMKgwqDCoMKgwqAgKGNsb3NlLW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RTBCMjVFMjhBMzNCMEI4NEY1NzcRHG1haWxAY2Jh aW5lcy5uZXQACgkQXiijOwuE9XdHAQ/9FOZ+tTSCY7vOpcJurYeKLmc0tzEGy7+L HJpmcB4j5RahbNveHs0arbd+/54lo3hHfPgBhQNF5wHV7o6Owt9Zwlzm66e8C93H YEDx/w1wkzmfw+txgWBswgX6imCoJC1YEM+OVWv/khoe6kvfRuMfwQ2QHJwIp/nm YFnmoEjZOMclLO1RaAe5+iF0Lok7dfpAAZDF8a1rJW6fcscHS4NhB3A9RJMVg8PH b/WdxgJvG4di1fpLH937gIEuzGIb85TAryZyKnIn24HSYPKyzRq7D3U87G/WpvrH x6hrNismkfuDz5l94BrBQspUQIrfgGhYvFvjQbQT4u+luGwNkm9ISg2LuU0dsevd oT/5rbPD66caXeNa3SE2R6C5UkIjlA6V5Kiiyk9cKCAlQewPxuGW8P0jIZc7gvip dtSYPJmOSe/PT5FVT7wIdb91iG001Oxs6tnlv6oCTO9hYslemTEhNTOmqdJ8FdE0 QSjesG10Jx0BTid1Mh9oCN+q3Jh0w2jUu7DbJnGAlj1pftsCkvATDA9hK80NOQV6 UA+MXdiTw7JYMH449H0Wvt2rVNc5xCk5gx4NfZpZzY4EeI4+4SW/fnpplNeCjhve 9eHUsAD1Xp2u6WRH1jQwSL0dOd/vucCfFAXJf9wk/QtsPq/LuLEry5+vI/fZeOjW 1AC7LSvZmhw= =BHgT -----END PGP SIGNATURE----- --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Mon Jun 27 07:55:21 2022 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 To: Ludovic =?utf-8?Q?Court=C3=A8s?= Subject: Re: bug#56218: [PATCH] guix: inferior: Fix the behaviour of open-inferior #:error-port. 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-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 56218 Cc: 56218@debbugs.gnu.org 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 (-) --=-=-= 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----- --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Tue Jul 05 11:13:11 2022 Received: (at 56218) by debbugs.gnu.org; 5 Jul 2022 15:13:11 +0000 Received: from localhost ([127.0.0.1]:51270 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1o8kEh-0007wI-04 for submit@debbugs.gnu.org; Tue, 05 Jul 2022 11:13:11 -0400 Received: from eggs.gnu.org ([209.51.188.92]:58930) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1o8kEc-0007vk-DJ for 56218@debbugs.gnu.org; Tue, 05 Jul 2022 11:13:09 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:57354) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o8kEX-0003W5-1K; Tue, 05 Jul 2022 11:13:01 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:In-Reply-To:Date:References:Subject:To: From; bh=akeeFMeScJsxUXvu5Kjc2AdPsLVSuExDLogndua9P6Q=; b=oZfXis7w46HCTtGSL783 9zu24kwODlLGQIsnegydeBd5q0RZ8gYezzH7qlXCnRnBb/BVg5bGsym2hBWS6vJQSehP3uHFqYzVw 4T7X7INbqlB9Kb+KYO5xNt7JNtSuxUZ1CCuApT0vd/dIvUsEG8G8035pqSdbW/gKKMdqX85HOEQrM 6RDJUiLmbAPzKU7QqoaSDvFs1gWXLz80Nm3/r386yD5irYf8PLB3YTG9zBCPYbH0Nbmwx/6SKitNZ e2dHwhjeBMxKAcGjiOLAMSaspjTv/Sy3sKj03+CITX1sUCsLRattLi2eOCvH0FZuOfer7LOhJ0ImR fnHouZBRU28wtg==; Received: from [193.50.110.235] (port=52066 helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o8kEW-0006iK-Jj; Tue, 05 Jul 2022 11:13:00 -0400 From: =?utf-8?Q?Ludovic_Court=C3=A8s?= To: Christopher Baines Subject: Re: bug#56218: [PATCH] guix: inferior: Fix the behaviour of open-inferior #:error-port. References: <20220625171847.29104-1-mail@cbaines.net> <87v8snqvf2.fsf@gnu.org> <87fsjql3rw.fsf@cbaines.net> Date: Tue, 05 Jul 2022 17:12:58 +0200 In-Reply-To: <87fsjql3rw.fsf@cbaines.net> (Christopher Baines's message of "Mon, 27 Jun 2022 12:39:55 +0100") Message-ID: <87o7y34mpx.fsf_-_@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 56218 Cc: 56218@debbugs.gnu.org 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 (---) Hi, Christopher Baines skribis: > Ludovic Court=C3=A8s writes: > >> Hi Christopher, >> >> Christopher Baines skribis: >> >>> This should be the error port used by the inferior process, but current= ly 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. OK, I think I got it. >>> + (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)) I prefer the original version: I find it clearer (it=E2=80=99s low-level) a= nd probably more robust (thinking through the port/FD interaction needs is more demanding :-)). >> 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. To sum up: I think it=E2=80=99s a welcome change, and it=E2=80=99s even mor= e welcome with a couple of tests to make sure it behaves the way we think it does. Thanks! Ludo=E2=80=99. From debbugs-submit-bounces@debbugs.gnu.org Fri Jul 08 08:57:11 2022 Received: (at 56218-done) by debbugs.gnu.org; 8 Jul 2022 12:57:12 +0000 Received: from localhost ([127.0.0.1]:59061 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1o9nXj-0001zO-KX for submit@debbugs.gnu.org; Fri, 08 Jul 2022 08:57:11 -0400 Received: from mira.cbaines.net ([212.71.252.8]:41372) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1o9nXg-0001zA-KA for 56218-done@debbugs.gnu.org; Fri, 08 Jul 2022 08:57:10 -0400 Received: from localhost (unknown [IPv6:2a02:8010:68c1:0:54d1:d5d4:280e:f699]) by mira.cbaines.net (Postfix) with ESMTPSA id 32D8327BBE9; Fri, 8 Jul 2022 13:57:05 +0100 (BST) Received: from felis (localhost [127.0.0.1]) by localhost (OpenSMTPD) with ESMTP id 48f14735; Fri, 8 Jul 2022 12:57:02 +0000 (UTC) References: <20220625171847.29104-1-mail@cbaines.net> <87v8snqvf2.fsf@gnu.org> <87fsjql3rw.fsf@cbaines.net> <87o7y34mpx.fsf_-_@gnu.org> User-agent: mu4e 1.6.10; emacs 28.1 From: Christopher Baines To: Ludovic =?utf-8?Q?Court=C3=A8s?= Subject: Re: bug#56218: [PATCH] guix: inferior: Fix the behaviour of open-inferior #:error-port. Date: Fri, 08 Jul 2022 13:54:24 +0100 In-reply-to: <87o7y34mpx.fsf_-_@gnu.org> Message-ID: <87ilo792zl.fsf@cbaines.net> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 56218-done Cc: 56218-done@debbugs.gnu.org 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 (-) --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Ludovic Court=C3=A8s writes: >>>> + (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)) > > I prefer the original version: I find it clearer (it=E2=80=99s low-level)= and > probably more robust (thinking through the port/FD interaction needs is > more demanding :-)). > >>> 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. > > To sum up: I think it=E2=80=99s a welcome change, and it=E2=80=99s even m= ore welcome > with a couple of tests to make sure it behaves the way we think it does. I've gone ahead and pushed a fix plus some tests as a9fd06121240c78071a398dd1e0ddb47553f3809. The tests probably aren't great, but I think the do cover the #:error-port behaviour. --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQKlBAEBCgCPFiEEPonu50WOcg2XVOCyXiijOwuE9XcFAmLIKZ5fFIAAAAAALgAo aXNzdWVyLWZwckBub3RhdGlvbnMub3BlbnBncC5maWZ0aGhvcnNlbWFuLm5ldDNF ODlFRUU3NDU4RTcyMEQ5NzU0RTBCMjVFMjhBMzNCMEI4NEY1NzcRHG1haWxAY2Jh aW5lcy5uZXQACgkQXiijOwuE9Xe74xAAiqmV9xooPtT1HHm8P/fj61XH8xO7pLOR EdSgsC5IVvBefxzPg6okh4NOGVq84/QBZO4p7eKlckp/5Oh5EjXOe/1/JLNJytd9 mqRnJv6jLtavQNQiQvdMkaSjt5ciWOpnbhjyKt9Gk5tB2Isb6JjliZxPK9I3Zh10 SeCvvAEwgGqvYR2e+176nHOKyYVX6iLaUd2tZV+MUWl1MX/05F5DSTNVF3t3fCZb SO/WjjCdFyDqL7l4is01ei//EVwml/Seb3TX/3Y24vHq0+Lyg0iXkhPrcJNKG37B ZitCflZ9T22HnZg6gEHpKnIQUzzACvaFJAFcc93ZeOM1fOFIlfVpcbZjII7we1Lt 6WYNXOq0ZOnQ7HS3+e8/H/rgRiwQQ0VLpyBPFi0+oWu+XrwBIXQ0bbt3xHLabnJV iNdoBiYvk6/nsQD6bPmneIjz1QkrD1She/GnKdFQaj7yvw4GsvQnC0h46IYrBSKM VWpQvtuToxbWDSmjKn42t1l1RwwnsxswSFvcCNaa7bguvqj+nIPDNo/xTTyP0E7c s460cJuhUBirW1vtDUVu4rv0+c4Yq/UCd6SVlUiDebpwIe4NhQaNVmm+eEn7YQTa 86zeHzEapQzmMpRvl0ZtGUMK67OcE5tTm8rs4bJrrpvmXxTmQ8zSL2bcK8P0YOI3 J5ILVTo0cBE= =tEX8 -----END PGP SIGNATURE----- --=-=-=-- From unknown Sat Jun 21 03:18:54 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Sat, 06 Aug 2022 11:24:05 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator