Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 (Denver Mods 7/26/84) 6/24/83; site drutx.UUCP Path: utzoo!watmath!clyde!burl!ulysses!mhuxr!ihnp4!drutx!zarth From: zarth@drutx.UUCP (CovartDL) Newsgroups: net.lang.c Subject: exit() from child and status in parent wait() Message-ID: <2530@drutx.UUCP> Date: Wed, 17-Apr-85 16:49:14 EST Article-I.D.: drutx.2530 Posted: Wed Apr 17 16:49:14 1985 Date-Received: Thu, 18-Apr-85 03:33:39 EST Organization: AT&T Information Systems Laboratories, Denver Lines: 41 I have been trying lately to use exit() in a child process and then have the parent recieve the exit code. This is so that if the exec fails the parent will not continue processing(or know to do error processing). The following is part of the code I am using. I would appreciate comments and/or suggestions. The printf statement shows rtn_code as 3 when the exec fails and therefore the error and cleanup code is never executed. # include int pid,wid; unsigned int rtn_code; if((pid = fork()) == NULL) { perror(); return(0); } else { if(pid == 0) { execl("cmd","cmd","arg",0); perror(); exit(16); } else { while((wid = wait((unsigned int *)rtn_code)) != pid); printf("%u\n",rtn_code); if(rtn_code == 16) { /* error processing and cleanup */ return(0); } else return(1); } } Post to the net or mail to me(drutx!zarth) whichever seems appropriate. Thanks in advance. Zarth Arn (alias Dave Coavrt) 1-303-538-4284