I really hope when the time comes and someone reinvents the wheel and comes up with a new great OS, the new OS will NOT have signals. Those are one of the worst things ever invented. The idea that your code is randomly interrupted and it starts to execute something else is just mind-blowingly bad. The real fun comes when you want to use different libraries with different signal handling ideas in the same process. It all goes to very quickly. The worst thing is that no one had the courage to say "okay guys, this is bad, let's just forget it ever existed and create a better alternative".
/rant
Signals are almost the app version of interrupts which is a fundamental way the peripherals (and your programs!) communicate with the kernel.
Sure handling them can be a pain in the ass, but I'd argue that signals are beautiful in their simplicity and extremely powerful. They are used for far more than signaling hang up and termination.
It should be noted that the example code is defective: printf() is being called inside the while loop and in the signal handler, which could lead to the printf() in the loop being interrupted by the signal handler, which would call printf() again, but printf() is not reentrant.
Doesn't ctrl-z actually send SIGTSTP rather than SIGSTOP? I think the difference is that SIGTSTP can be caught, while SIGSTOP is always an unconditional stop.
I like the use of jprobes to show the call stack within the kernel. I wish all of the tracing functionality within Linux would have one API (like DTrace). I considered writing a module to provide such an API, but there's so many complications when trying to create conditional probes (you don't have enough power with eBPF, and the default string-based globbing is useless).
I keep meaning to learn Linux from the ground up, by following the bootloader assembly, kernel initialisation etc and be able to track it in the kernel code, but its so vast I forget half of it, as I try to make my way (sporadically) through all there is.
[+] [-] nemaar|9 years ago|reply
[+] [-] smcl|9 years ago|reply
[+] [-] rwl4|9 years ago|reply
Sure handling them can be a pain in the ass, but I'd argue that signals are beautiful in their simplicity and extremely powerful. They are used for far more than signaling hang up and termination.
[+] [-] zAy0LfpBZLC8mAC|9 years ago|reply
[+] [-] FreeFull|9 years ago|reply
[+] [-] zvrba|9 years ago|reply
[+] [-] cyphar|9 years ago|reply
[+] [-] nul_byte|9 years ago|reply
There are so many hours in the day.
[+] [-] jdub|9 years ago|reply
https://github.com/0xAX/linux-insides
[+] [-] seesomesense|9 years ago|reply
I am trying to read this book from cover to cover while I am in hospital. It is vastly more entertaining than the cable TV.
[+] [-] Razengan|9 years ago|reply
[+] [-] brudgers|9 years ago|reply
https://hn.algolia.com/?query=linux%20signals&sort=byPopular...