/* * Exercise 3-10 child code. */ #include #include #include #include #include int main(int argc, char *argv[]) { pid_t pid; int ret_value; pid=getpid(); ret_value=(int)(pid%256); srand((unsigned) pid); sleep(rand()%5); if(atoi(*(argv+1))%2) { printf("Child %d is terminating with signal 0008\n", pid); kill(pid, 9); } else { printf("Child %d is terminating with exit(%04X)\n", pid, ret_value); exit(ret_value); } } /* adimitro@alef:/student/adimitro/cwork/ch3> ./parent Forked child 17918 Child 17919 is terminating with signal 0008 Forked child 17919 Forked child 17920 Child 17920 is terminating with exit(0000) Wait on PID: 17920 returns status: 0000 Wait on PID: 17919 returns status: 0088 Child 17918 is terminating with exit(00FE) Wait on PID: 17918 returns status: FE00 adimitro@alef:/student/adimitro/cwork/ch3> /* The signals currently defined by are as follows: Name Value Default Event SIGHUP 1 Exit Hangup (see termio(7I)) SIGINT 2 Exit Interrupt (see termio(7I)) SIGQUIT 3 Core Quit (see termio(7I)) SIGILL 4 Core Illegal Instruction SIGTRAP 5 Core Trace or Breakpoint Trap SIGABRT 6 Core Abort SIGEMT 7 Core Emulation Trap SIGFPE 8 Core Arithmetic Exception As we can see from the definition the SIGFPE creates a core file, dumps a core... whatever you want to call it and that would set the leftmost bit of the low byte to 1 and then the signal was 8 so in bin it would be 0000 0000 1000 1000 which is 0x0088 Cheers */