I've got a program to catch any terminating signals. Currently all it does is catch Ctrl + C. I want to be able to catch Ctrl + Z and Ctrl + \ in addition to Ctrl + C. Here's part of my code.
if (signal(SIGINT, SIG_IGN) == SIG_ERR)
fprintf(stderr,"Error: Can't catch SIGINT\n");
if (signal(SIGTERM, SIG_IGN) == SIG_ERR)
fprintf(stderr,"Error: Can't catch SIGTERM\n");
// do stuff
What other signals to I need to implement to catch Ctrl + Z and Ctrl + \? And what raises
SIGTERM? Thanks in advance.
Ctrl+Z raises SIGTSTP. Ctrl+\ raises SIGQUIT.
I don't know of any key combination that raises SIGTERM, but of course you can send it using
kill -TERM <pid> replacing
<pid> with the process ID. (Or just
kill <pid>; SIGTERM is the default signal for
Note that you can't catch SIGSTOP nor SIGKILL.