Bug 18621 – core.sync.condition notify methods cannot be used from a (unix) signal handler
Status
CLOSED
Resolution
INVALID
Severity
enhancement
Priority
P1
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2018-03-16T12:03:55Z
Last change time
2018-03-16T12:22:41Z
Assigned to
No Owner
Creator
James E. King III
Comments
Comment #0 by jking — 2018-03-16T12:03:55Z
Using core.stdc.signal I can set up a signal handler to handle SIGINT (^C), however signal handlers have a limited set of things they can do. The handler must be nothrow and @nogc.
pthread_cond_signal and pthread_cond_broadcast are safe to call in a signal handler and typically used to trigger shutdowns, however core.sync.condition has no safe method that can be called to notify or notifyAll.
Would it be possible to add a "nothrow @nogc" safe version of these methods that return an error code instead of throw so that core.sync.condition can be used in a (unix) signal handler? Thanks.
Hi, on further review it seems condition variables are not safe to use from signal handlers, according to https://linux.die.net/man/3/pthread_cond_signal therefore I am closing this as invalid.