From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms9.migadu.com with LMTPS id 6OIGH1AHVWRURQEASxT56A (envelope-from ) for ; Fri, 05 May 2023 15:40:32 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id yORMH1AHVWSrDQEA9RJhRA (envelope-from ) for ; Fri, 05 May 2023 15:40:32 +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 112DE3EC03 for ; Fri, 5 May 2023 15:40:32 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1puvfM-0007Go-DD; Fri, 05 May 2023 09:40:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1puvfH-0007FR-JZ for bug-guix@gnu.org; Fri, 05 May 2023 09:40:04 -0400 Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1puvfH-0005AE-BO for bug-guix@gnu.org; Fri, 05 May 2023 09:40:03 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1puvfH-0005po-76 for bug-guix@gnu.org; Fri, 05 May 2023 09:40:03 -0400 X-Loop: help-debbugs@gnu.org Subject: bug#63024: [PATCH 2/3] Use /dev/null in piped-process if port is not backed by a fdes Resent-From: Josselin Poiret Original-Sender: "Debbugs-submit" Resent-CC: bug-guix@gnu.org Resent-Date: Fri, 05 May 2023 13:40:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 63024 X-GNU-PR-Package: guix X-GNU-PR-Keywords: To: Ludovic =?UTF-8?Q?Court=C3=A8s?= , Josselin Poiret Cc: 63024@debbugs.gnu.org, 62334@debbugs.gnu.org, Greg Hogan , Simon Tournier Received: via spool by 63024-submit@debbugs.gnu.org id=B63024.168329397022304 (code B ref 63024); Fri, 05 May 2023 13:40:03 +0000 Received: (at 63024) by debbugs.gnu.org; 5 May 2023 13:39:30 +0000 Received: from localhost ([127.0.0.1]:53440 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1puvek-0005nX-An for submit@debbugs.gnu.org; Fri, 05 May 2023 09:39:30 -0400 Received: from jpoiret.xyz ([206.189.101.64]:53666) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1puveh-0005n5-QJ; Fri, 05 May 2023 09:39:28 -0400 Received: from authenticated-user (jpoiret.xyz [206.189.101.64]) by jpoiret.xyz (Postfix) with ESMTPA id 58568185317; Fri, 5 May 2023 13:39:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jpoiret.xyz; s=dkim; t=1683293967; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=KkAM1YWQOOqvOGUFC0lPa0IxcuKTRj08RPUOkWCxRCY=; b=eateAvRXfy+6YEgFEYX7c4yLBBrmc/EDTfsYFpmPlxm1lw1Sg7rW55iY7o8pbyXVaB0MJk 4OMx2kAdg79KbzY4WjVGIX0r/C8Jg01GIAo24w99K7aK8/nw+pAF72WGpjMBCt9lnkPG8d dg/lIKruBMXQxtf7gnyawrT98F6sWFEEgVrh7Ung5xEXggRjm3+ZO8FSUMAOISst51kxPa MYv1OMTuvmgndiooRD0s7P9NA0isNcc4tqxnJ7S8V58DkIHGb8aefrgHQId1NQLk9UByuc 2kow8gAr8pkko+bFC3ZEWGkFe7dRGGVMpg92MH+FgN8KHOA7F67SANkPa8Ya9A== Date: Fri, 5 May 2023 15:39:23 +0200 Message-Id: <269750b29a104e35a6bbd92e267130cfcf35c33e.1683293896.git.dev@jpoiret.xyz> In-Reply-To: <87mt2l4whd.fsf@gnu.org> References: <87mt2l4whd.fsf@gnu.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spamd-Bar: ++++++ X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-guix@gnu.org List-Id: Bug reports for GNU Guix List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-to: Josselin Poiret From: Josselin Poiret via Bug reports for GNU Guix Errors-To: bug-guix-bounces+larch=yhetil.org@gnu.org Sender: bug-guix-bounces+larch=yhetil.org@gnu.org X-Migadu-Country: US X-Migadu-Flow: FLOW_IN ARC-Seal: i=1; s=key1; d=yhetil.org; t=1683294032; a=rsa-sha256; cv=none; b=OV8Wx7iGTJ/lYhiBKyotDZs+85+vHIYYaeg7yRJ75KC0CFU4jy4xl6TDUZ2DBy0TyDMhi/ f1NCjSa+4XcbO7/fWTDLmTG4pu0N+6+bTDLiAGxFJE2p8aa+IPqp37Ifv5GMhUnXaeCYOq zYr63sRdGaIXznt1aEJt2uwReIEVPwS3vfp7hqxOQrOsv8ziQoN57Sy7922BDMHYgDSj07 JeQITraGbXKT91r8RsOJiQul4+aaBJ2MPdpAcH7j2oZhW1Ugi36/fETNPv4CFbtYcdBl48 dANXX4bx5UtyVuW6F+//eD2YSm2t3GhZGRfW0+Y3H0/e340GyI3m/PoUpiYqrg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=jpoiret.xyz header.s=dkim header.b=eateAvRX; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of "bug-guix-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="bug-guix-bounces+larch=yhetil.org@gnu.org" ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1683294032; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: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:dkim-signature; bh=KkAM1YWQOOqvOGUFC0lPa0IxcuKTRj08RPUOkWCxRCY=; b=YRyL5r3L3DOxeMUbGvxfoQHMc2GSIAmnoEDg38XmpWhYwNsaIug+dEgXtKhK6RDc4bhG3y estCQ2VhCE4SZruZmwnJQMcXC7VwajueOdbCJZbldUDuYqNsqZfpEHyo20uavkYvazhrh1 7R7F/9i4w4hH1chbVo44aPv6ARfq4KQX6wQepoS32BhJ8eJskzcFCv0tAZwvwdpwonQvTe 2R3vrZQ+X6qOUCmpLmMYRcQb9uGzla9gLAU3rol72Xi8Ye9BxRM76td8QBLhfAjET3Gshb 99ChrKsKCcF9AbDTYIQ6FOkEAWLlw9ofS6hCvJmEp2wDb7QhQ3Y1aUwD/xLBBg== X-Migadu-Spam-Score: 5.79 X-Spam-Score: 5.79 X-Migadu-Queue-Id: 112DE3EC03 X-Migadu-Scanner: scn0.migadu.com Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=jpoiret.xyz header.s=dkim header.b=eateAvRX; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of "bug-guix-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="bug-guix-bounces+larch=yhetil.org@gnu.org" X-TUID: eBa9ZsPLH8CX From: Josselin Poiret * libguile/posix.c (piped_process): Open /dev/null to use as in/out/err if the corresponding port is not backed by a file descriptor. --- libguile/posix.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/libguile/posix.c b/libguile/posix.c index 2969f1f24..f41a99efe 100644 --- a/libguile/posix.c +++ b/libguile/posix.c @@ -1558,10 +1558,22 @@ piped_process (pid_t *pid, SCM prog, SCM args, SCM from, SCM to) if (SCM_OPOUTFPORTP ((port = scm_current_error_port ()))) err = SCM_FPORT_FDES (port); - if (out == -1 && SCM_OPOUTFPORTP ((port = scm_current_output_port ()))) - out = SCM_FPORT_FDES (port); - if (in == -1 && SCM_OPINFPORTP ((port = scm_current_input_port ()))) - in = SCM_FPORT_FDES (port); + else + err = open ("/dev/null", O_WRONLY | O_CLOEXEC); + if (out == -1) + { + if (SCM_OPOUTFPORTP ((port = scm_current_output_port ()))) + out = SCM_FPORT_FDES (port); + else + out = open ("/dev/null", O_WRONLY | O_CLOEXEC); + } + if (in == -1) + { + if (SCM_OPINFPORTP ((port = scm_current_input_port ()))) + in = SCM_FPORT_FDES (port); + else + in = open ("/dev/null", O_RDONLY | O_CLOEXEC); + } } *pid = do_spawn (exec_file, exec_argv, exec_env, in, out, err, 1); -- 2.39.2