I am trying to catch signals in c and ignore them for the parent process while the child handles them normally. I currently have:
#include<signal.h>
#include<bits/sigaction.h>
int main(){
struct sigaction parentsig, childsig;
parentsig.sa_handler = SIG_IGN;
sigaction(SIGINT, &parentsig, &childsig);
return 0;
}
I am currently compiling it with gcc -std=c99 -o smallsh smallsh.c
, but I get the error implicit declaration of function ‘sigaction’
. After some debugging I found out that it has to do with sigaction(SIGINT, &parentsig, &childsig)
line. Every example that I can find has something similar to this since it sets what struct to follow when handling signals. Can someone explain what I'm doing wrong with this?