Hi All,
I am still trying to write a custom shell and I want to handle SIGINT and SIGTSTP, so I assigned them handlers (like it is customary for my people):
Code:
signal(SIGINT, sigint_handler);
signal(SIGTSTP, sigtstp_handler);
The problem is:
When waiting for the user input, like so:
Code:
fgets(lineSize, MAX_LINE_SIZE, stdin);
If I press CTRL+z / CTRL+c the handlers will not be invoked until I press ENTER.
And when I am waiting on a running a command like so:
Code:
pID=fork();
if(pID ==-1){
printf("error...");
return;
} else if(pID == 0) {
execvp(args[0], args);
printf("error...");
return;
} else {
wpID=wait(&status);
if(wpID == -1){
printf("error...");
}
return;
}
And I press CTRL+z / CTRL+c the handlers are not invoked at all and the program gets stuck.
Anybody has an idea what the problem might be?
Thanks a lot