all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Maxim Cournoyer <maxim.cournoyer@gmail.com>
To: "Ludovic Courtès" <ludo@gnu.org>
Cc: 30948@debbugs.gnu.org, Carlo Zancanaro <carlo@zancanaro.id.au>
Subject: bug#30948: [PATCH core-updates] guix: Reap finished child processes in build containers.
Date: Mon, 28 Nov 2022 21:07:47 -0500	[thread overview]
Message-ID: <875yeysebw.fsf@gmail.com> (raw)
In-Reply-To: <87lenvce8r.fsf@gnu.org> ("Ludovic Courtès"'s message of "Mon, 28 Nov 2022 16:04:04 +0100")

Hi,

Ludovic Courtès <ludo@gnu.org> writes:

> Maxim Cournoyer <maxim.cournoyer@gmail.com> skribis:
>
>> Ludovic Courtès <ludo@gnu.org> writes:
>
> [...]
>
>>> If I write:
>>>
>>>   (gexp->derivation "foo" #~(mkdir #$output))
>>>
>>> I can be sure that my derivation depends on nothing but (default-guile).
>>> This is important for tests, but also to make sure we can use this
>>> primitive everywhere—if it pulled in the Shepherd, I wouldn’t be able to
>>> use to build glibc, because there’d be a cycle.
>>
>> I was not suggesting to pull in extra dependencies such as Shepherd, but
>> to weave the to-be-added signal handling logic at a much lower level.
>> One idea could be to arrange so that the correct signal handlers always
>> get installed for any Guile code running in the build side (I'm not sure
>> how, but perhaps by adjusting the gexp "compiler"?).
>>
>> The handlers could be defined in (guix build signal-handling) or
>> similar.  Users wouldn't need to explicitly import the module and
>> install its signal handlers, that'd be taken care of automatically, all
>> the time.
>>
>> Does that sound feasible?
>
> Not like this: the imported-modules derivation for (guix build
> signal-handling) would be a dependency in themselves.

I see a couple of options for the lowest place to inject the minimal
signal handling of a PID.

1. In Guile itself.  We could make it detect when it's running as PID 1
and then set up the required signal handling.  This is apparently what
Bash does, a peculiarity exploited by NixOS (they launch their builder
scripts via Bash, which is PID 1 and takes care of reaping the dead
processes)

2. In a Guile wrapper.  Instead of running Guile directly in the
container, guix-daemon would run it through a wrapper that acts as PID 1.
This would make it a tool comparable to dumb-init [0] or tini [1],
except written in Scheme.

[0] https://github.com/Yelp/dumb-init/
[1] https://github.com/krallin/tini

If we implement 1, it'd make Guile potentially useful as a wrapper
itself to launch scripts in containerized environment (the same as
tini), and it alleviates any integration overhead for us, so I find it
attractive.

What do you think?

For further reading, see [2], which I found interesting.

[2]  https://medium.com/hackernoon/my-process-became-pid-1-and-now-signals-behave-strangely-b05c52cc551c

-- 
Thanks,
Maxim




  parent reply	other threads:[~2022-11-29  2:08 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-26 11:16 [bug#30948] [PATCH core-updates] guix: Reap finished child processes in build containers Carlo Zancanaro
2018-03-26 23:39 ` Carlo Zancanaro
2018-03-29 20:07 ` Ludovic Courtès
2018-03-29 21:15   ` Carlo Zancanaro
2018-03-30  8:16     ` Ludovic Courtès
2018-03-30 11:17       ` Carlo Zancanaro
2018-03-30 15:17         ` Ludovic Courtès
2022-11-24 16:40           ` Maxim Cournoyer
2022-11-24 16:44           ` bug#30948: " Maxim Cournoyer
2022-11-26 15:11             ` Ludovic Courtès
2022-11-27  3:00               ` Maxim Cournoyer
2022-11-28 15:04                 ` Ludovic Courtès
2022-11-28 20:10                   ` Maxim Cournoyer
2022-11-29  2:07                   ` Maxim Cournoyer [this message]
2023-12-17 20:23                   ` bug#30948: [PATCH core-updates] build-system/gnu: Turn PID 1 into an “init”-style process by default Ludovic Courtès
2023-12-17 21:46                     ` Maxim Cournoyer
2023-12-18 17:46                       ` bug#30948: [PATCH core-updates] guix: Reap finished child processes in build containers Ludovic Courtès
2023-12-30  3:36                         ` Maxim Cournoyer
2023-12-19 22:56                     ` 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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=875yeysebw.fsf@gmail.com \
    --to=maxim.cournoyer@gmail.com \
    --cc=30948@debbugs.gnu.org \
    --cc=carlo@zancanaro.id.au \
    --cc=ludo@gnu.org \
    /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 external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.