Subject: Re: bug#52835: [PATCH 0/2] Fix spawning a child not setting standard fds properly

From: Josselin Poiret <[email-masked]>
Date: Fri, 23 Dec 2022 18:15:03 +0100

Hi Ludo, thanks for the quick review and fixes.

> I pushed it to ‘wip-posix-spawn’ along with fixups I’m proposing, mostly
> along the lines of what I suggested in
> <https://issues.guix.gnu.org/52835#18>:

Nice but also see below.

> I also added Andrew Whatson’s patch from
> <https://issues.guix.gnu.org/59321>.

Great, hadn't see that one go by!

> If that’s fine with you, I can squash the “fixup!” commits and merge the
> branch.  Let me know!
>
> Earlier we agreed it’d be nice to expose ‘spawn*’/‘primitive-spawn’.  I
> still think it’s a good idea, but the interface would need some work IMO
> to be more generally useful.  In essence, we could provide something
> similar to ‘fork+exec-command’ in the Shepherd, where one can pass
> environment variables, stdin/stdout/stderr, etc., all that with keyword
> arguments and reasonable defaults.

I've just polished it up a bit: the `spawn*` procedure defined in C now
takes another argument, a list of environment variables.  I think this
interface is good enough to cover most use cases, if anyone needs
something more complicated they should go through their own C code.
I've added a convenience module (ice-9 spawn) with a `spawn` procedure
in it, which takes an optional argument list which defaults to just the
executable, and optional environment variables as well as in, out and
err ports.  I also think everything in (ice-9 popen) should be migrated
on the next major release, as well as being re-implemented in terms of
`spawn` purely, so that the change is immediately noticeable.

We're reaching the bike-shedding time now, but IMHO having such a
`spawn*` exposed to the user seems fine, it's a pretty simple "raw"
interface with fdes, and there is a convenience `spawn` function that is
nicer for users.

Do we need to add a documentation page as well?

Best,
-- 
Josselin Poiret