I have problem with handling signals. I run program in terminal, I am pressed CTRL + C, but don't see "I am pressed CTRL-C" wasn't printed. But I am trying delete row execl("/usr/bin/gedit", "gedit", "test.c", NULL)
, "I am pressed CTRL-C" was printed.
Can I help you, how to print "I am pressed CTRL-C" and explain why it is. I am appreciated of your help. Thank you very much.
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <signal.h>
int loop_forever = 1;
void on_sigint()
{
printf("\nI am pressed CTRL-C\n");
loop_forever = 0;
}
int main()
{
printf("My homework\n");
execl("/usr/bin/gedit", "gedit", "test.c", NULL);
signal(SIGINT, on_sigint);
while (loop_forever)
{
}
exit(1);
}