unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
From: ludo@gnu.org (Ludovic Courtès)
To: Jelle Licht <jlicht@fsfe.org>
Cc: 27553@debbugs.gnu.org
Subject: [bug#27553] [PATCH shepherd] Register SIGCHLD handler after primitive fork
Date: Mon, 17 Jul 2017 10:33:03 +0200	[thread overview]
Message-ID: <87wp77ea4g.fsf@gnu.org> (raw)
In-Reply-To: <CAPsKtfKyjaoKmtekfFfM1ZWmE-eT8ibVqg-7QEA5UCTBQF4nNw@mail.gmail.com> (Jelle Licht's message of "Fri, 14 Jul 2017 14:19:12 +0200")

Hi Jelle,

Jelle Licht <jlicht@fsfe.org> skribis:

> 2017-07-12 23:34 GMT+02:00 Ludovic Courtès <ludo@gnu.org>:
>
>> Hi Jelle,
>>
>> Jelle Licht <jlicht@fsfe.org> skribis:
>>
>> > I am not sure if this is also the proper ML for the GNU Shepherd, but
>> > looking in the archives lead me to believe it actually is. If not, I
>> > suggest the gnu.org page for shepherd be updated with the correct info.
>>
>> It’s the right list.  :-)
>>
> I am glad it turned out to be :-). Perhaps [1] can be updated to the same
> info as [2]?

Done!

>> > I recently starting playing around with user shepherd, and found out that
>> > when running a shepherd 0.3.2 daemonized as non-init process (via
>> "(action
>> > 'shepherd 'daemonize)"), zombie processes are created whenever you start
>> > and subsequently stop any service.
>> >
>> > Thinking I did something wrong, I asked lfam on #guix to share his (very
>> > helpful) init.scm for user shepherd, yet I still noticed the same
>> behaviour.
>> >
>> > I believe commit `efa2f45c5f7dc735407381b7b8a83d6c37f828db'
>> inadvertently
>> > introduced an ordering issue, where the SIGCHLD handler is registered
>> > /before/ shepherd has the chance to daemonize. I believe the following
>> > trivial patch addresses this snafu.
>>
>> The config file can start services, so the SIGCHLD handler must be
>> installed before we read the config file (otherwise we could be missing
>> some process termination notifications.)
>>
> What do you mean exactly? I think my config file does this, and I have not
> yet noticed this issue,
> but I might just be confused about what you mean here.

If the config file spawns a process and that process dies before we have
installed the SIGCHLD handler, then we’ll never know that it has
terminated.

>> Perhaps a solution would be to install the SIGCHLD handler lazily upon
>> the first ‘fork+exec-command’ call?  That would ensure both that (1)
>> users have a chance to daemonize before the handler is installed, and
>> (2) that the handler is installed before services are started.
>>
>> Thoughts?
>>
> This seems like it would be for the best. I actually have no clue how to
> implement this though.

I’d imagine something like a global variable (a Boolean) telling whether
the SIGCHLD handler is installed, and then:

  (unless %sigchld-handler-installed?
    (sigaction …)
    (set! %sigchld-handler-installed? #t))

Thoughts?

Ludo’.

  reply	other threads:[~2017-07-17  8:34 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-02  1:11 [bug#27553] [PATCH shepherd] Register SIGCHLD handler after primitive fork Jelle Licht
2017-07-12 21:34 ` Ludovic Courtès
2017-07-14 12:19   ` Jelle Licht
2017-07-17  8:33     ` Ludovic Courtès [this message]
2017-07-27 14:32       ` Jelle Licht
2017-09-06 22:56         ` Jelle Licht
2017-09-07 14:49           ` bug#27553: " 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

  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=87wp77ea4g.fsf@gnu.org \
    --to=ludo@gnu.org \
    --cc=27553@debbugs.gnu.org \
    --cc=jlicht@fsfe.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 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).