errormsg in childprozess

Bjorn Engsig bengsig at dk.oracle.com
Wed Mar 27 00:35:51 AEST 1991


[I'm taking this over to comp.unix.programmer)

Article <91.082.19:00:19 at mute.ruhr.de> by frank at mute.ruhr.de (Frank Huemme) says:
|
|ret=fork();
|if (ret==0)			/* in child */
|	{
|	execlp(.........
|	exit();
|	}
|
|My Problem:
|What`s the best way for the child to tell the father-process if something
|was going wrong with execlp ( and fork() was ok )??
The problem is that it is much easier to test and report errors in the
mother program.  In the case above, you use the execlp call which will look
up in the PATH for you.  If you are willing to do this yourself (or you
already have the complete path of the new executable), you can do most of
the checking before calling fork().  You can easily check if the executable is
there, if it has execute permission, etc.  If so, do fork and exec, and you
can do with a simple and crude way of reporting errors, e.g. print to stderr,
and _exit(somevalue), since the most common errors are found even before
fork().

-- 
Bjorn Engsig, ORACLE Corporation, E-mail: bengsig at oracle.com, bengsig at oracle.nl



More information about the Comp.unix.programmer mailing list