This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: libiberty/pex-unix vfork abuse?
- From: Ian Lance Taylor <iant at google dot com>
- To: "Dave Korn" <dave dot korn at artimi dot com>
- Cc: <gcc at gcc dot gnu dot org>
- Date: 07 Dec 2007 08:59:28 -0800
- Subject: Re: libiberty/pex-unix vfork abuse?
- References: <05ea01c838e3$001b9b40$2e08a8c0@CAM.ARTIMI.COM>
"Dave Korn" <dave.korn@artimi.com> writes:
> Note the several calls to dup2() and close(), which seem to me to be "calls
> [to] any other function", and the setting of environ, which seem to me to be
> modification of "any data other than a variable of type pid_t used to store
> the return value from vfork()".
Despite the standardese, vfork was invented to support calling
dup/dup2 before calling exec. Without that feature, it would be
nearly useless. Any actual implementation of vfork must support
calling dup/dup2, or it will break all real programs which use vfork.
On the other hand, the setting of environ is very dubious and is
likely to break on real systems. The code should be changed to call
execve instead. Unfortunately there is no standard execvpe function.
Fortunately gcc never uses the variant which sets environ. Offhand
I'm not sure what does.
Ian