Subject: [bug#54205] [PATCH Shepherd] Factor out a public CALL-IN-FORK.

From: Maxime Devos <[email-masked]>
Date: Tue, 01 Mar 2022 13:47:09 +0100

Attila Lendvai schreef op di 01-03-2022 om 08:06 [+0100]:
> their service is started.  One such example is calling setrlimit from a start
> action to set NOFILE (the open files limit), before the service is exec'ed and
> thus inherits this value from the parent process, i.e. from Shepherd.

'fork+exec-command' already accepts a 'environment-variables' and
'file-creation-mask', how about adding an 'open-file-limit' argument?
To me, that seems more declarative and less fragile than having
to call 'call-in-fork' manually in a 'start' procedure (*).

Support for other rlimits can be added on an as-needed basis.
Alternatively, the argument could be generalised to a more general
'rlimit' argument:

  #:rlimits
  `((,RLIMIT_AS ,SOFT ,HARD)
    (,RLIMIT_NPROC ,SOFT ,HARD)
    (,RLIMIT_NOFILE ,SOFT ,HARD))

WDYT?

Greetings,
Maxime.

(*) E.g., one of the ideas for making shepherd faster, was using some
kind of multi-threading.  Forking when multi-threading is ill-defined
(see POSIX) though, so some kind of zygote process + IPC might be
necessary
(http://neugierig.org/software/chromium/notes/2011/08/zygote.html has a
nice explanation on zygote processes, the bits about software updates
can be ignored here).