Linux signal handling - notifying a condition variable

Dmitry Olshansky dmitry.olsh at gmail.com
Thu Mar 15 19:41:10 UTC 2018


On Thursday, 15 March 2018 at 19:36:44 UTC, Patrick Schluter 
wrote:
> On Thursday, 15 March 2018 at 19:23:26 UTC, Dmitry Olshansky 
> wrote:
>> On Thursday, 15 March 2018 at 17:30:50 UTC, Jim King wrote:
>>> [...]
>>
>> Another option if you are on linux is to use eventfd. Then you 
>> can trigger it with simple write on eventfd descriptor.
>>
>> As far as waiting goes it’s either read on descriptor or 
>> poll/select.
>> f it seems a bit more involved.
>>> [...]
>>
>> However I’d be super careful about mutexes with signal 
>> handlers. Really self-pipe trick or eventfd seems way more 
>> signal safe.
>
> There's also signalfd which is quite practical to change 
> signals in select/poll/epoll events.

Indeed, handling SIGINT termination in an event loop is easiest. 
Just need to mask the signal out, somewhat counter-intuitively.




More information about the Digitalmars-d mailing list