#include <cstdio> #include <unistd.h> #include <signal.h> #include <sys/types.h> #include <sys/wait.h> void handler(int signo) { if (signo == SIGCHLD) { printf("Recall SIGINT\n"); wait(NULL); } else if (signo == SIGALRM); } void myalarm(int sec) { alarm(sec); pause(); } int main() { signal(SIGCHLD, handler); signal(SIGALRM, handler); pid_t pid= fork(); if (pid < 0) { perror("fork"); return -1; } else if (pid == 0) { myalarm(10); } else if (pid > 0) { while (1) { myalarm(1); } } return 0; }