Path: utzoo!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!samsung!crackers!m2c!jjmhome!lectroid!denap From: denap@alta.sw.stratus.com (Tom DeNapoli) Newsgroups: comp.unix.programmer Subject: Re: Detecting exec(2) failing after performing fork(2)? Message-ID: Date: 4 Mar 91 14:12:54 GMT References: <1991Mar1.205944.13198@crc.skl.dnd.ca> Sender: usenet@lectroid.sw.stratus.com Organization: Society for the Toleration of a Single Fault. Lines: 31 In-reply-to: rosenqui@crc.skl.dnd.ca's message of 1 Mar 91 20:59:44 GMT >>>>> On 1 Mar 91 20:59:44 GMT, rosenqui@crc.skl.dnd.ca (Eric Rosenquist) said: [original post deleted] rosenqui> It's too late once the fork() has completed. What you need to do is rosenqui> have the child exit in a particular way that your SIGCLD handler looks rosenqui> for if the exec() fails. In your code snippet the child keeps rosenqui> executing! rosenqui> if (fork() == 0) { rosenqui> execlp(path, NULL); rosenqui> /* if you get here, the exec() failed */ rosenqui> exit(SOME_STATUS_CODE); rosenqui> /* or */ rosenqui> abort() or kill(...) etc. rosenqui> } along the same lines... prior to exiting the child could use a write back to the parent through a pipe with more details of the failure. rosenqui> Eric @ SKL rosenqui> ------------- rosenqui> Eric.Rosenquist@crc.skl.dnd.ca rosenqui> Software Kinetics Limited rosenqui> 65 Iber Road, Stittsville, Ontario rosenqui> Canada - K2S 1E7 Phone (613) 831-0888 -- Tom DeNapoli | Stratus Computer, Inc. denap@alta.sw.stratus.com | 55 Fairbanks Blvd M23EN3 uunet!lectroid!alta!denap | Marlboro, MA 01752