I'm making a basic shell in C and I want to catch Ctrl+C so that it doesn't kill my program, but instead kills all processes running under my program. I don't know what code to set put in my signal handler to get this effect.
Furthermore, once I have the code to catch SIGINT and get it to not kill my process, would I put it globally in my program, or would I put it in it's own function which I run in main at some point, or would I put it where the processes are created and executed function int execCmd(char **cmds){...}
for example?
Many thanks in advance for any help and advice.