unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
From: ludo@gnu.org (Ludovic Courtès)
To: Carlo Zancanaro <carlo@zancanaro.id.au>
Cc: 30637@debbugs.gnu.org
Subject: [bug#30637] [WIP] shepherd: Poll every 0.5s to find dead forked services
Date: Wed, 28 Feb 2018 23:06:06 +0100	[thread overview]
Message-ID: <87y3jcu5v5.fsf@gnu.org> (raw)
In-Reply-To: <878tbe9jvx.fsf@zancanaro.id.au> (Carlo Zancanaro's message of "Wed, 28 Feb 2018 08:56:34 +1100")

Hi Carlo,

Carlo Zancanaro <carlo@zancanaro.id.au> skribis:

> Another patch for shepherd!

Always welcome!  :-)

> The problem is that shepherd, when run as a user process, can "lose"
> services which fork away. Shepherd can still kill them, but a SIGCHLD
> won't be delivered if they die, so shepherd can't restart/disable
> them. My prime example is emacs, which I run with --daemon. If I then
> kill emacs, shepherd will still think that it is running.

There are two issues here, I think.

  1. shepherd cannot lose SIGCHLD: if a process dies immediately once
     it’s been spawned, as is the case with “emacs --daemon” or any
     other daemon-style program, it should receive SIGCHLD and process
     it.

     However, there could be a race condition: if SIGCHLD is handled
     before the ‘running’ value has been set, then we’ll still get the
     non-#f ‘running’ value even though the process died in the
     meantime.

     The code tries to prevent that (see (shepherd service) around line
     320), but looking more closely, I think the race is still there.
     Namely, the whole ‘let’ block, including the call to ‘start’,
     should be in ‘call-with-blocked-asyncs’, I think.  Could you check
     if that helps for you?

  2. shepherd currently can’t do much with real daemons.  So what we do
     in GuixSD is to either start programs in non-daemon mode, when
     that’s an option, or pass #:pid-file to retrieve the forked process
     PID.  I think you should do one of these as well.

WDYT?

Thanks,
Ludo’.

  reply	other threads:[~2018-02-28 22:07 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-27 21:56 [bug#30637] [WIP] shepherd: Poll every 0.5s to find dead forked services Carlo Zancanaro
2018-02-28 22:06 ` Ludovic Courtès [this message]
2018-03-01 22:37   ` Carlo Zancanaro
2018-03-02  9:44     ` Ludovic Courtès
2018-03-02 10:13       ` Carlo Zancanaro
2018-03-02 12:42         ` Ludovic Courtès
2018-03-03  7:58           ` Carlo Zancanaro
2018-03-03 15:21             ` Ludovic Courtès
2018-03-03 20:49               ` Carlo Zancanaro
2018-03-04 22:11                 ` Ludovic Courtès
2018-03-04 22:35                   ` Carlo Zancanaro
2018-03-04 22:49                     ` Ludovic Courtès
2018-03-04 23:08                       ` Carlo Zancanaro
2018-03-05 14:15                         ` bug#30637: " 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=87y3jcu5v5.fsf@gnu.org \
    --to=ludo@gnu.org \
    --cc=30637@debbugs.gnu.org \
    --cc=carlo@zancanaro.id.au \
    /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).