Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!sdd.hp.com!spool.mu.edu!snorkelwacker.mit.edu!hsdndev!cmcl2!adm!smoke!gwyn From: gwyn@smoke.brl.mil (Doug Gwyn) Newsgroups: comp.lang.c Subject: Re: errormsg in childprozess Message-ID: <15562@smoke.brl.mil> Date: 25 Mar 91 08:09:43 GMT Article-I.D.: smoke.15562 References: <91.082.19:00:19@mute.ruhr.de> Organization: U.S. Army Ballistic Research Laboratory, APG, MD. Lines: 21 In article <91.082.19:00:19@mute.ruhr.de> frank@mute.ruhr.de (Frank Huemme) writes: >ret=fork(); >if (ret==0) /* in child */ > { > execlp(......... > exit(); > } >What`s the best way for the child to tell the father-process if something >was going wrong with execlp ( and fork() was ok )?? This is a UNIX-specific question, better asked in comp.unix.questions. However, the answer is that there are several possible solutions. Note first of all that "exit()" is incorrect; exit() requires an argument, and that is one method of reporting failure to the parent, which if it wait()s on the child will be able to use the exit status to determine whether of not the child had a problem. (Actually you should use _exit() in this context, to avoid unwanted flushing of the forked copy of the stdio buffers.) If the parent is not waiting on the child, you could send a signal from the child branch to the parent branch before the child branch terminates, and have the parent use a signal handler to set a flag that you can test at appropriate places.