Earlier quoted context omitted.
I think the kqueue interface is a lot worse than the Linux way. With kqueue everything is forced through one interface. In Linux it's just file descriptors and epoll to deal with them. It is a nice extension of the "everything is a file" mechanism and it embodies the "do one thing and do it right". This becomes apparent when you look at fs notifications. You've already mentioned how inotify is superior to kqueue. I m…
There's been talk (at BSDCam) of implementing inotify which is needed for the Linuxulator and exposing it in the FreeBSD API too. So your wish isn't so far fetched but I'm not sure anyone is actively working on it. Patches welcome :)
How Not to Write a Signal Handler
21–30 of 52 posts
Re: How Not to Write a Signal Handler
#22Re: How Not to Write a Signal Handler
#23… and then the article goes completely omitting sigqueue+sigwaitinfo (realtime signals)
Re: How Not to Write a Signal Handler
#24Re: How Not to Write a Signal Handler
#25Re: How Not to Write a Signal Handler
#26They write: "It is the 2013th year in the Common Era at the moment of this writing and you might think that people should have came up with something better in terms of signal handling at this time. The truth is that they did. It is just not that well known yet due to a huge momentum of outdated information still overflowing the Internet." Then they talk about kqueue. The above paragraph emphasizes how much Unix prog…
Turns out compatibility and understandability is really useful, and it's good to define your complex systems in terms of simple systems. Worse is better.
Re: How Not to Write a Signal Handler
#27I still don't understand how queueing signals works. For example, signalfd() is really cool, and you can indeed read() a signal from it, but only one of a kind. If you get, say, two SIGINT's you may as well just be able to read() one. I guess it's an implementation detail that some signals aren't queued while some others are, I guess. In practice it means that receiving a signal is an edge, and in signal handler you…
What's a good use case for knowing how many times a signal was raised? Signal once raised has no more context than the signal itself.
Example: Pressing one Ctrl-C will display a message like this on some programs (which do not want to terminate themselves upon receiving a single SIGINT, because accidents happen): "Press Ctrl-C again to quit."
Re: How Not to Write a Signal Handler
#28I still don't understand how queueing signals works. For example, signalfd() is really cool, and you can indeed read() a signal from it, but only one of a kind. If you get, say, two SIGINT's you may as well just be able to read() one. I guess it's an implementation detail that some signals aren't queued while some others are, I guess. In practice it means that receiving a signal is an edge, and in signal handler you…
As an extension, there are "real-time" signals as well, which are queued - linux implement them, see e.g. http://man7.org/linux/man-pages/man7/signal.7.html
Re: How Not to Write a Signal Handler
#29Is there a reason they are using sleep(1) instead of pause()? Seems like a waste to use sleep if all you are doing is waiting for a signal.
Re: How Not to Write a Signal Handler
#30Earlier quoted context omitted.
What's a good use case for knowing how many times a signal was raised? Signal once raised has no more context than the signal itself.
If the signal is received more than once it means it is more important :p "Oh shit!" "^C^C^C^C^C^C~C^C"
Reasonably sure that can't be done in C even with all that undefined behaviour.
However, if your IO monad implementation is sufficiently slow, you could ^C between when you thought the code had executed and when it actually bothered to get around to it.
I can't believe that none of the functional ninjas thought to add time travel as a benefit. Most remiss...