-
Notifications
You must be signed in to change notification settings - Fork 5
Description
Not sure about Windows, but I'm pretty sure that at least POSIX signal handlers act like a goto that jumps out of your code's normal execution at whatever arbitrary point the signal occurred in order to execute the callback handler - any call stack in any thread could be interrupted to execute the signal handler.
It looks like the Linux implementation of LinuxCatcher() gets plugged in as the POSIX signal handler, and directly calls EventFuction(), which in turn directly calls user handlers, so it would be susceptible to this.
I'm wondering if it would be safer to run an internal thread that sleeps on a condition variable and calls EventFunction() whenever it gets woken up by a notification, and then have the catcher simply notify the condition variable. This would allow the catcher to complete more quickly, while also guaranteeing that user handlers are always called from a clean call stack in a dedicated thread.