From: Josselin Poiret via Bug reports for GNU Guix <bug-guix@gnu.org>
To: "Ludovic Courtès" <ludo@gnu.org>, "Josselin Poiret" <dev@jpoiret.xyz>
Cc: 63024@debbugs.gnu.org, 62334@debbugs.gnu.org,
Greg Hogan <code@greghogan.com>,
Simon Tournier <zimon.toutoune@gmail.com>
Subject: bug#63024: [PATCH 2/3] Use /dev/null in piped-process if port is not backed by a fdes
Date: Fri, 5 May 2023 15:39:23 +0200 [thread overview]
Message-ID: <269750b29a104e35a6bbd92e267130cfcf35c33e.1683293896.git.dev@jpoiret.xyz> (raw)
In-Reply-To: <87mt2l4whd.fsf@gnu.org>
From: Josselin Poiret <dev@jpoiret.xyz>
* 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
next prev parent reply other threads:[~2023-05-05 13:40 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-21 14:17 bug#62334: Network is unreachable only for recursive pypi import Greg Hogan
2023-03-21 21:45 ` Josselin Poiret via Bug reports for GNU Guix
2023-03-24 12:19 ` Maxim Cournoyer
2023-04-24 8:42 ` zimoun
2023-03-28 20:37 ` bug#62334: Network Travis Zimmerman
2023-04-25 12:23 ` bug#62334: Network is unreachable only for recursive pypi import Simon Tournier
2023-04-27 13:32 ` Simon Tournier
2023-05-02 21:47 ` bug#62334: bug#63024: Crash during `guix import pypi -r' Ludovic Courtès
2023-05-02 21:48 ` Ludovic Courtès
2023-05-03 9:04 ` bug#62334: " Ludovic Courtès
2023-05-03 10:08 ` bug#63024: " Simon Tournier
2023-05-04 11:10 ` Ludovic Courtès
2023-05-05 13:39 ` bug#62334: [PATCH 1/3] Add error handling for spawn's posix_spawn_file_actions_adddup2 Josselin Poiret via Bug reports for GNU Guix
2023-05-08 14:08 ` bug#63024: Guile's "sleep pipe" can leak into processes created by 'spawn' Ludovic Courtès
2023-05-05 13:39 ` Josselin Poiret via Bug reports for GNU Guix [this message]
2023-05-05 13:39 ` bug#62334: [PATCH 3/3] tests: Test that system* works if stdin/out/err isn't backed by fdes Josselin Poiret via Bug reports for GNU Guix
2023-05-04 11:13 ` bug#63024: Crash during `guix import pypi -r' Ludovic Courtès
2023-05-05 8:54 ` bug#57391: " Ludovic Courtès
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://guix.gnu.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=269750b29a104e35a6bbd92e267130cfcf35c33e.1683293896.git.dev@jpoiret.xyz \
--to=bug-guix@gnu.org \
--cc=62334@debbugs.gnu.org \
--cc=63024@debbugs.gnu.org \
--cc=code@greghogan.com \
--cc=dev@jpoiret.xyz \
--cc=ludo@gnu.org \
--cc=zimon.toutoune@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/guix.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).