Process control query (4.2 BSD)

Brett Galloway brett at wjvax.UUCP
Fri Jan 24 10:15:38 AEST 1986


Last week I posted a query to the net about communicating the success or
failure of an execve() from inside a fork() to the parent process.  I got
several responses (thank you).  I finally decided to create a pipe between
the child and the parent.  If the child's execve() fails, it writes

	write(fd,&errno,sizeof(errno))
	
down the pipe and _exit()'s.  If the child's execve() succeeds, the pipe gets
closed automatically, because I explicitly mark the close on exec flag for
the pipe in the parent).  Meanwhile, the parent sits on the other end of
the pipe.  If it sees EOF (read(fd,&errno_save,sizeof(int) == 0)), it
knows the execve() succeeded.  Otherwise, it gets the error code
returned by exeve().

Apparently, the only way for the parent to detect the difference between the
child's execve() failing or succeeding and exiting very quickly is by
using a scheme as above, which explicitly communicates the success/failure of
the execve() from the child to the parent.

-------------
Brett Galloway
{pesnta,twg,ios,qubix,turtlevax,tymix,vecpyr,certes,isi}!wjvax!brett



More information about the Comp.unix.wizards mailing list