all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Jelle Licht <jlicht@fsfe.org>
To: "Ludovic Courtès" <ludo@gnu.org>
Cc: guix-devel <guix-devel@gnu.org>
Subject: Re: Improving Shepherd
Date: Thu, 15 Feb 2018 18:05:43 +0100	[thread overview]
Message-ID: <871shmji8o.fsf@fsfe.org> (raw)
In-Reply-To: <87a7wbu2ht.fsf@gnu.org>


Ludovic Courtès <ludo@gnu.org> writes:

> Heya,
>
> Jelle Licht <jlicht@fsfe.org> skribis:
>
>> Good news: signfalfd seems to work as far as I can see. I am 
>> not quite sure
>> how to make it work consistently with guile ports yet though.
>
> Good!  What do you mean by “work with guile ports” though?
>

It seems that I am running into problems with the way guile 
handles
signals atm. As far as I understood the good people of #guile on
freenode, guile handles signals with a separate thread that 
actually
makes sure signal handling is done at the 'right' time. As such, 
it
seems that there is no easy way to set the mask of blocked signals 
for
all guile threads.

My approach was to wrap `pthread_sigmask' (initially 
`sigprocmask') icw
a call to `signalfd', but it seems that "my" guile thread only 
receives
the signal about ~two-thirds of the time. This only happens when
triggering the signal via 'external' means, such as the kill 
command.
Using the `raise' function from within my guile repl/program did 
always
reliably trigger events coming in on my signalfd based port.

Without being able to block all relevant signals via 
`pthread_sigmask'
from the other guile threads, it seems very difficult to reliably 
use
signalfd based ports to handle signals. Some (ugly) code at [1]
demonstrates this: run the guile script, and find the pid of the 
guile
process via `pgrep', and then send a SIGCHLD signal via `kill -17
<pid>'. You should still see the signal handler for the supposedly
blocked signal be triggered.

tl;dr: I cannot seem to block signals from being handled by guile 
in
some way, which to me seems a prerequisite for using 
signalfd-based
signal handling. My uneducated guess is that guile needs to 
support a
way to set signal masks for all threads in order to deal with 
this.


>> To make use of signalfd, one normally masks signals so that 
>> these can
>> handled via signalfd instead of the default signal handlers; 
>> any process
>> forked start out with the same signal mask, so we would need to 
>> make
>> sure to either reset the signal mask for spawned processes.
>
> Right, we could do that in ‘exec-command’, which is the central 
> place
> for fork+exec.

Right, this does not seem as difficult as I initially thought. If 
the
earlier things I mentioned are resolved/worked around, this should 
be
easy to implement.
>
> Well, let us know what to do next, then!  :-)
>
> Ludo’.

-Jelle

[1]: https://paste.debian.net/1010454/

  reply	other threads:[~2018-02-15 17:06 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-29 21:14 Improving Shepherd Carlo Zancanaro
2018-01-29 22:27 ` Jelle Licht
2018-02-05 10:49 ` Carlo Zancanaro
2018-02-05 13:08   ` Ludovic Courtès
2018-02-05 15:56     ` Carlo Zancanaro
2018-02-09 13:26       ` Ludovic Courtès
2018-02-09 19:50         ` Carlo Zancanaro
2018-02-09 21:32         ` Christopher Lemmer Webber
2018-02-14 13:10           ` Ludovic Courtès
2018-02-15 13:55             ` Andy Wingo
2018-02-10 13:34     ` Jelle Licht
2018-02-14 13:25       ` Ludovic Courtès
2018-02-15 17:05         ` Jelle Licht [this message]
2018-02-15 19:04           ` Mark H Weaver
2018-02-05 16:00   ` Danny Milosavljevic
2018-02-05 16:41     ` Carlo Zancanaro
2018-02-09 13:22     ` Ludovic Courtès
2018-02-09 20:51       ` David Pirotte

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=871shmji8o.fsf@fsfe.org \
    --to=jlicht@fsfe.org \
    --cc=guix-devel@gnu.org \
    --cc=ludo@gnu.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 external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.