I got this program my friend sent me. And were both new at ubuntu and she asked me what will happen if we enter ctrl-c on the terminal
#include <signal.h>
#include <stdio.h>
void catch(int signo) {
printf("Signal %d caught\n", signo);
sleep(2);
}
int main() {
int i;
struct sigaction act;
act.sa_flags = 0;
act.sa_handler = catch;
sigfillset(&(act.sa_mask));
if (sigaction(SIGINT, &act, NULL) != 0) {
perror("sigaction");
exit(1);
}
for (i = 0; i < 100; ++i) {
printf("sleep %d ....\n", i);
sleep(1);
}
exit(0);
}
#include <unistd.h>
for thesleep()
function it is missing the statement:#include <stdlib.h>
for theexit()
function