i wrote a code to handle when CTRL C presses and to ignore CTRL Z signal
i am trying to run a donothing.c file from within my code but it does not run
donothing.c literally is just an infinite loop printing nothing
Trying that to see if after exec it does go back to default handler from parent
here is my code
Code:
#include <signal.h>
#include <stdio.h>
#include <unistd.h>
void sigHandler(int sig)
{
signal(SIGINT, sigHandler);
printf("CTRL C does not work\n");
}
int main(int argc, char *argv[]){
int pid;
pid = fork();
if(pid == 0){
char* args[2] ;
args[0] = "./donothing";
args[1] = 0;
execvp(args[0], args);
//execl("donothing", NULL);
}else if(pid > 0){
signal(SIGINT, sigHandler);
kill(pid, SIGINT);
}
}