4 ms·
> a traditionally hairy problem in UNIX programming: how to wait for two different types of events (signals and file descriptors) at the same time. I've always
by amelius 11y ago
> a traditionally hairy problem in UNIX programming: how to wait for two different types of events (signals and file descriptors) at the same time.
I've always thought one of the weak points of POSIX was that the event sources were not unified. Imho, is a pity the relevant committee didn't work towards a clean solution in the mean time.
- okigan 11y agoSame here! Also annoying is inability to wake up when any (vs all) child threads are done. Even more annoying is that Windows API allows to wait on any combination of file/socket descriptor and/or message[1]. [1] MsgWaitForMultipleObjects https://msdn.microsoft.com/en-us/library/windows/desktop/ms684242(v=vs.85).aspx https://msdn.microsoft.com/en-us/library/windows/desktop/ms6...
- uep 11y agoI know we're talking about POSIX here, but Linux does have the ability to wait on signals the same way it waits on file descriptors. It does this by also allowing signals to be delivered on file descriptors. http://man7.org/linux/man-pages/man2/signalfd.2.html http://man7.org/linux/man-pages/man2/signalfd.2.html
- hyc_symas 11y agoGratuitous fluff. Writing to a pipefd inside a signal handler works on all POSIX systems.
- JdeBP 11y agoWinding forward to the present: I recommend a look at kevent/kqueue.