From: "Ludovic Courtès" <ludo@gnu.org>
To: Kevin Boulain <kevinboulain@gmail.com>
Cc: guix-devel@gnu.org
Subject: Re: Should Guix Home daemonize Shepherd?
Date: Sun, 15 May 2022 15:20:32 +0200 [thread overview]
Message-ID: <87lev3dja7.fsf@gnu.org> (raw)
In-Reply-To: <CABaj1X_coHxvcvMOwZXPYazsfrN3aXs793QUio2VquUrYKEOHA@mail.gmail.com> (Kevin Boulain's message of "Sat, 12 Mar 2022 18:49:21 +0100")
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’.
next prev parent reply other threads:[~2022-05-15 13:20 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-06 18:47 Should Guix Home daemonize Shepherd? Kevin Boulain
2022-03-12 17:49 ` Kevin Boulain
2022-05-06 8:07 ` Andrew Tropin
2022-05-15 13:20 ` Ludovic Courtès [this message]
2022-05-15 18:39 ` Kevin Boulain
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
List information: https://guix.gnu.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87lev3dja7.fsf@gnu.org \
--to=ludo@gnu.org \
--cc=guix-devel@gnu.org \
--cc=kevinboulain@gmail.com \
/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 public inbox
https://git.savannah.gnu.org/cgit/guix.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).