3 ms·
Arrgh. How does an article titled "All about Linux signals" not even mention the signalfd() syscall once? Folks: if you're on Linux and need to use signals (i
by ajross 15y ago
Arrgh. How does an article titled "All about Linux signals" not even mention the signalfd() syscall once? Folks: if you're on Linux and need to use signals (i.e. you're reading this article for any practical reason), you need to be using signalfd(). It's not portable to other OSes, but it solves pretty much all the reentrancy and synchronization issues discussed both here and in the article in a very clean way. You get a file descriptor on which you can block cleanly (c.f. select/poll/epoll) and from which you read event notifications on received signals.
Seriously, use it. And OP: please update the blog post to at least point people at it. There's no excuse on a modern linux system for trying to use anything else.
- krakensden 15y agoIt is, you just missed it. FTFA: > First we must block the signals we want to handle with signalfd(2) using sigprocmask(2). This function will be described later. Then we call signalfd(2) to create a file descriptor...
- ajross 15y agoOK, I call uncle. I can't find that text. It's not on the page titled "waiting for a signal", which seems like the obvious candidate. Nor is it in "signals and threads", which would have been my second choice. Nor "That's not everything!". Enlighten me with a link?
- krakensden 15y agoI clicked "show full page", but I think it's on page 3 http://www.linuxprogrammingblog.com/all-about-linux-signals?page=3 http://www.linuxprogrammingblog.com/all-about-linux-signals?...
- halayli 15y agohttp://www.linuxprogrammingblog.com/all-about-linux-signals?page=3 http://www.linuxprogrammingblog.com/all-about-linux-signals?... http://www.linuxprogrammingblog.com/code-examples/signalfd http://www.linuxprogrammingblog.com/code-examples/signalfd I just wish freebsd and linux folks agree on a standard instead of dealing with multiple ways to handle async events via different poller implementations and hacks.