From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id OKG9J/opyGJ4XAEAbAwnHQ (envelope-from ) for ; Fri, 08 Jul 2022 14:58:34 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id aF3NJvopyGKQYQEAG6o9tA (envelope-from ) for ; Fri, 08 Jul 2022 14:58:34 +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 561473C58C for ; Fri, 8 Jul 2022 14:58:34 +0200 (CEST) Received: from localhost ([::1]:47974 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o9nZ3-00040M-6V for larch@yhetil.org; Fri, 08 Jul 2022 08:58:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56232) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o9nYZ-0003vk-6z for guix-patches@gnu.org; Fri, 08 Jul 2022 08:58:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:36937) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o9nYY-0003Gp-Tp for guix-patches@gnu.org; Fri, 08 Jul 2022 08:58:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1o9nYY-00022h-SJ for guix-patches@gnu.org; Fri, 08 Jul 2022 08:58:02 -0400 Subject: bug#56218: [PATCH] guix: inferior: Fix the behaviour of open-inferior #:error-port. Resent-From: Christopher Baines Original-Sender: "Debbugs-submit" Resent-To: guix-patches@gnu.org Resent-Date: Fri, 08 Jul 2022 12:58:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: cc-closed 56218 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Ludovic =?UTF-8?Q?Court=C3=A8s?= Cc: 56218-done@debbugs.gnu.org Mail-Followup-To: 56218@debbugs.gnu.org, mail@cbaines.net, mail@cbaines.net Received: via spool by 56218-done@debbugs.gnu.org id=D56218.16572850327655 (code D ref 56218); Fri, 08 Jul 2022 12:58:02 +0000 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 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-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=1657285114; 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-to: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=9FYQFLVHFWI0Htwexx9nTsaCUSYYaktdVmaHRvPyb4g=; b=rzbhRWuSpluhilX3YQzIEljW0sDq9KttbqDd+Btdrwb5sVAxOXJLpS/uk/9fj8I1Qvcaxt OblgfhIK5vbbTo93xR7MgzvZdz07wu8vTIc0tC21Yb7g7D7TYfrqcMKfpBlDHexXdL2JYd WuSM7MpZl7Hi33FUT547ybuxI85ntDN/e9VPw9HD+r9y/01QwyYWl82mDjnZYnTHubAwLZ U1GMlIAld3oHjOubdlqlqb9spNeZSm8kh6lNobntvuvW28ZfqD0IWkf2DaBZV53o+bULhn x43hO1hhA66Ij8akOkQt4xVAzMuTNefaxX4uGoeNkEiycTbpgMAzTggTYrLDog== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1657285114; a=rsa-sha256; cv=none; b=taR8hBIwfNkS3mE0/7YMETGMLyseH5As86vnruTKQVzwVCjoiXT9JkMwKk0f7XLad3JoSE E3t6vQ4Kuzj8bzh3D1pAa6XQzyZPVzq5Da8jZMbPfzOdiiZawgaXZSwOWcWsDJ/yfCUTRw L7Win2/AkWdrrdrRmQ5ZyTiaYfvVRDhj0sHQKWhSto8BiRcI82HmZLILioUt+He5ApdNyN 1riJWCBGOrsBk/9wOPC/x8YFUPJyI/OMuFbRLQaWtDy6tejGJ1VVF0Qucmd5VWZEQqMwPO o0yVFOPxEg6xEBS+3V3LghRNZ1/w3Uhug/o4Tk//kNjKEKUVpgzAMvv+iw6LrA== 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: -6.35 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: 561473C58C X-Spam-Score: -6.35 X-Migadu-Scanner: scn0.migadu.com X-TUID: 6eHNLdDJgsaK --=-=-= 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----- --=-=-=--