943,971 Members | Top Members by Rank

Ad:
  • C Code Snippet
  • Views: 510
  • C RSS
0

A question about signal

by on Oct 29th, 2009
This code is just handling the SIGCHLD signal, but as you can see, the parent process should ignore this SIGCHLD signal according to the signal function. But in fact, the parent process will omit the signal function, and handling the child process using "wait". I wonder why the parent do not ignore the SIGCHLD signal?
C Code Snippet (Toggle Plain Text)
  1. 1int main(argc,argv) {
  2. 2 int argc;
  3. 3 char *argv[] int i,ret_val,ret_code;
  4. 4 if(argc>1)
  5. 5 signal(SIGCLD,SIG_IGN);
  6. 6 for(i=0;i<10;i++)
  7. 7 if(fork()==0) {
  8. 8 printf("child proc %x\n",getpid());
  9. 9 exit(i);
  10. 10 }
  11. 11 ret_val=wait(&ret_code);
  12. 12 }
Message:
Previous Thread in C Forum Timeline: open file as soon asyou run a command. How?
Next Thread in C Forum Timeline: problem regarding trees in data structures using c





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC