#include #include #include #include #include #include #define BUF_SIZE (4096*256) volatile static int signal_parent = 0; void mysig(int sig) { int status; pid_t pid; printf("Signal %d \n", sig); if (sig == SIGALRM) { signal_parent = 1; } if (sig == SIGCLD) { // harvest terminated DEFUNCT child process pid = waitpid(-1, &status, WNOHANG); printf(" Child Process(%d) terminated with a status of %d\n", pid, status); } } /* In main, we tell the child process to wait for ten seconds before sending a SIGALRM signal to its parent. */ int main() { int pid; int sum; char * buf; int i,j; printf("child process starting\n"); if((pid = fork()) == 0) { buf = (char *) malloc(BUF_SIZE); if(buf == NULL) { exit(1); } for(j=0;j<10;j++) { for(i=0;i