#include #include #include #include int main(void) { int i; void signal_catcher(int); if (signal(SIGINT, signal_catcher)==SIG_ERR) { perror("SIGINT"); exit(1); } if (signal(SIGQUIT, signal_catcher)==SIG_ERR) { perror("SIGQUIT"); exit(2); } for (i=0; ; ++i) { printf("%d\n", i); sleep(1); } } void signal_catcher(int the_sig) { signal(the_sig, signal_catcher); printf("\nSignal %d received.\n", the_sig); } /* You can tell what I used below for the signal to kill it with one can do jobs but no need for it if you are not running any other BG processes So assuming that you are then first i do jobs then look at the lines and see which one is the ./a.out then i do kill -HUP %1 SIGKILL will also work on it as well as others too I guess. this could also be done very well with ps and then again kill. adimitro@alef:/student/adimitro/cwork/ch4> ./a.out & [1] 2202 0 [Logged in : 1] adimitro@alef:/student/adimitro/cwork/ch4> 1 jobs [1]+ Running ./a.out & [Logged in : 1] adimitro@alef:/student/adimitro/cwork/ch4> 2 kil3 l -4 HU5 P 6 %1 [1]+ Hangup ./a.out [Logged in : 1] adimitro@alef:/student/adimitro/cwork/ch4> */