Can someone please explain the difference between sigaction and signal. I know they signal works differently depending on which machine you are working on i.e. Mac, Windows, or Linux and that sigaction works the same on all platforms. But my question is why is that, because I have tried using signal on different platforms and have gotten the same result. Also which one would you guys recommend using for better practice.
Asked
Active
Viewed 929 times
1
-
Possible duplicate of [What is the difference between sigaction and signal?](http://stackoverflow.com/questions/231912/what-is-the-difference-between-sigaction-and-signal) – pilcrow May 03 '16 at 15:47
1 Answers
3
I know few things about sigaction
and signal
. But what i know is that:
sigaction
call is more complex to use thansignal
call (as you already know).sigaction
allows you to obtain more information about the signal received by your program (seesiginfo_t
structure).- According to Michael KERRISK's book : "The Linux Programming Interface" (Ch. 22, page: 456) : "...it is good practice always to use
sigaction
, rather thansignal
to establish signal handlers." - Finally (again from Michael KERRISK's book): "The Linux kernel contains an implementation of
signal
as system call, this implementation provides the older, unreliable semantics. However,glibc
bypasses this system call by providing a signal library function that callssigaction
"
Hope it helps.

oneshepherdssheep
- 88
- 7