Linux signal handling - notifying a condition variable
James E. King III
jking at apache.org
Fri Mar 16 12:20:52 UTC 2018
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.
More information about the Digitalmars-d
mailing list