From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Newsgroups: gmane.lisp.guile.bugs Subject: bug#52835: [PATCH 0/2] Fix spawning a child not setting standard fds properly Date: Sun, 25 Dec 2022 18:03:48 +0100 Message-ID: <873593xvnv.fsf_-_@gnu.org> References: <87v8m2jb3c.fsf@jpoiret.xyz> <388cbca36850d1837b3c478d9bd9dd5e222215b0.1671815759.git.dev@jpoiret.xyz> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="20229"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) Cc: 52835@debbugs.gnu.org To: Josselin Poiret Original-X-From: bug-guile-bounces+guile-bugs=m.gmane-mx.org@gnu.org Sun Dec 25 18:04:30 2022 Return-path: Envelope-to: guile-bugs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1p9UQH-00051b-T1 for guile-bugs@m.gmane-mx.org; Sun, 25 Dec 2022 18:04:30 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p9UPt-0000JR-8r; Sun, 25 Dec 2022 12:04:05 -0500 Original-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 1p9UPr-0000JB-3P for bug-guile@gnu.org; Sun, 25 Dec 2022 12:04:03 -0500 Original-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 1p9UPq-0003vm-DZ for bug-guile@gnu.org; Sun, 25 Dec 2022 12:04:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1p9UPp-0006ZF-Rl for bug-guile@gnu.org; Sun, 25 Dec 2022 12:04:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: bug-guile@gnu.org Resent-Date: Sun, 25 Dec 2022 17:04:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 52835 X-GNU-PR-Package: guile X-GNU-PR-Keywords: patch Original-Received: via spool by 52835-submit@debbugs.gnu.org id=B52835.167198783925235 (code B ref 52835); Sun, 25 Dec 2022 17:04:01 +0000 Original-Received: (at 52835) by debbugs.gnu.org; 25 Dec 2022 17:03:59 +0000 Original-Received: from localhost ([127.0.0.1]:50049 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p9UPm-0006Yx-MM for submit@debbugs.gnu.org; Sun, 25 Dec 2022 12:03:58 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:36506) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p9UPl-0006Yl-1d for 52835@debbugs.gnu.org; Sun, 25 Dec 2022 12:03:57 -0500 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p9UPf-0003TF-KM; Sun, 25 Dec 2022 12:03:51 -0500 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=ROul/PbkArqpB9lYNc/RsUayLE3Yp2TOjbeDw+i8pxc=; b=Zef0hov85hMm2mVc/VKp ONdaw+5BFE4MZ57/Sfw1vijbfnVeGb4xYM2JPfDu+wtOafmdzDsfH9pHGkmdv9K4cOU34KTOqS5g/ QbdoXTdf9mz5qcIVVlOVyggIChARnt+UZG58jsq7hh5Gy5Dwd+n7qjmD7tGG9weL0q1POd/BBiLsC C7AGKvej3TmiSC/OF//QjO0rt7nriTSVoahRB95HvfVNNIPaU4Wmh5EGfBMA9jO7BgJOBdsSX0/VS O2z7wzOpTIGPlBS/Fcal7LE2V3k75glAJkOhWK9BSj7E+GIsJS3KV6VRBiSqVc+Vw6a9Gee5lWPsT +VpmP9sBInP3kQ==; Original-Received: from 91-160-117-201.subs.proxad.net ([91.160.117.201] helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p9UPf-0007Ru-11; Sun, 25 Dec 2022 12:03:51 -0500 In-Reply-To: <388cbca36850d1837b3c478d9bd9dd5e222215b0.1671815759.git.dev@jpoiret.xyz> (Josselin Poiret's message of "Fri, 23 Dec 2022 18:17:05 +0100") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-guile@gnu.org List-Id: "Bug reports for GUILE, GNU's Ubiquitous Extension Language" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guile-bounces+guile-bugs=m.gmane-mx.org@gnu.org Original-Sender: bug-guile-bounces+guile-bugs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.lisp.guile.bugs:10491 Archived-At: Josselin Poiret skribis: > * libguile/posix.c: Include spawn.h from Gnulib. > (do_spawn, scm_spawn_process): New functions. > * module/ice-9/spawn.scm: New file > (spawn): New procedure. > --- > libguile/posix.c | 82 ++++++++++++++++++++++++++++++++++++++++++ > libguile/posix.h | 2 ++ > module/ice-9/spawn.scm | 54 ++++++++++++++++++++++++++++ > 3 files changed, 138 insertions(+) The new module should be added to =E2=80=98am/bootstrap.am=E2=80=99. > +SCM_API SCM scm_spawn_process (SCM prog, SCM args, SCM env, > + SCM in, SCM out, SCM err); Let=E2=80=99s keep it =E2=80=98SCM_INTERNAL=E2=80=99. > +(define* (spawn exec-file > + #:optional (args (list exec-file)) > + #:key (env (environ)) > + (in (current-input-port)) > + (out (current-output-port)) > + (err (current-error-port))) s/exec-file/program/ s/args/arguments/ s/env/environment/ s/in/standard-input/ s/out/standard-output/ s/err/standard-error/ Maybe we could allow these two be either ports or file descriptors? > + "Spawns a new process running the program @var{exec} with arguments > +@var{args}, in the environment specified by the list of environment > +variable strings @var{env}, and with standard input, output and error > +set to the ports specified by @var{in}, @var{out}, @var{err}. Note that > +the last part only works with fd-backed ports." > + (let* ((in (port-with-defaults in "r")) > + (out (port-with-defaults out "w")) > + (err (port-with-defaults err "w")) > + ;; Increment port revealed counts while to prevent ports GC'ing= and > + ;; closing the associated fds while we spawn the process. > + (result (spawn* exec-file > + args > + env > + (port->fdes in) > + (port->fdes out) > + (port->fdes err)))) I believe =E2=80=98spawn*=E2=80=99 is unbound here because it=E2=80=99s def= ined by =E2=80=98scm_init_popen=E2=80=99, which is called within the (ice-9 popen) = module. Ludo=E2=80=99.