guix-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Should Guix Home daemonize Shepherd?


From: Ludovic Courtès
Subject: Re: Should Guix Home daemonize Shepherd?
Date: Sun, 15 May 2022 15:20:32 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)

Hi,

Kevin Boulain <kevinboulain@gmail.com> skribis:

> First, Guix Home correctly tells the user Shepherd to daemonize itself
> via an 'action'
> (https://git.savannah.gnu.org/cgit/guix.git/tree/gnu/home/services/shepherd.scm#n64)
> but, from my understanding, the daemonization process is missing at
> least a setsid call
> (https://git.savannah.gnu.org/cgit/shepherd.git/tree/modules/shepherd/service.scm#n1421),
> see the attached 'shepherd-setsid.patch'. This fixes the Shepherd
> dying when exiting the SSH session or the Shepherd catching the ^C.
> I guess it should also close std{in,out,err} like it's done for the
> regular services
> (https://git.savannah.gnu.org/cgit/shepherd.git/tree/modules/shepherd/service.scm#n806)
> but this answers a part of my initial post.

[...]

> Detach from the controlling terminal when daemonizing
>
> https://lists.gnu.org/archive/html/guix-devel/2022-03/msg00040.html
>
> diff --git c/modules/shepherd/service.scm w/modules/shepherd/service.scm
> index ad8608b..62f97bc 100644
> --- c/modules/shepherd/service.scm
> +++ w/modules/shepherd/service.scm
> @@ -1420,8 +1420,12 @@ we want to receive these signals."
>            (else
>             (if (zero? (primitive-fork))
>                 (begin
> -                 (catch-system-error (prctl PR_SET_CHILD_SUBREAPER 1))
> -                 #t)
> +                 (setsid)
> +                 (if (zero? (primitive-fork))
> +                     (begin
> +                       (catch-system-error (prctl PR_SET_CHILD_SUBREAPER 1))
> +                       #t)
> +                     (primitive-exit 0)))

The extra ‘setsid’ call LGTM, but why add an extra ‘primitive-fork’
call?

Thanks in advance,
Ludo’.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]