On Thursday, 15 March 2018 at 19:43:09 UTC, Patrick Schluter
wrote:
On Thursday, 15 March 2018 at 16:51:59 UTC, Jim King wrote:
I am trying to add graceful shutdown support to a test harness.
In the test harness, a server class consumes a thread to
accept connections and service them. In order to stop the
server, it has to be interrupted. This interruption mechanism
is based on core.sync.condition.
I want to add a signal handler so that if SIGINT is received,
the server is interrupted and stops gracefully.
signalfd [1] is a good solution on Linux.
core.sys.linux.sys.signalfd;
[1]: http://man7.org/linux/man-pages/man2/signalfd.2.html
Thank you, this looks like the best solution. On further reading
I found that
it is not safe to use condition variables from signal handlers,
per the documentation in
https://linux.die.net/man/3/pthread_cond_signal.