Reputation: 12431
int sigaction(int signum, const struct sigaction *act, struct sigaction *oldact);
If act is non-NULL, the new action for signal signum is installed from act. If oldact is non-NULL, the previous action is saved in oldact.
This comes from https://linux.die.net/man/2/sigaction, I don't quite understand what "previous action" means. Does it means the action by default referred to the signum
? I've tested the code as below but it gave me a core dumped:
#include <signal.h>
#include <unistd.h>
struct sigaction act, oact;
void func(int p)
{
oact.sa_handler(p); # core dumped here
}
int main(int argc, char **argv)
{
act.sa_handler = func;
sigaction(SIGINT, &act, &oact);
sleep(100);
return 0;
}
Upvotes: 1
Views: 195