Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 11 Oct 1998 02:06:17 -0700 (PDT)
From:      Matthew Dillon <dillon@backplane.com>
To:        Peter Wemm <peter@netplex.com.au>
Cc:        Bruce Evans <bde@FreeBSD.ORG>, cvs-committers@FreeBSD.ORG, cvs-all@FreeBSD.ORG
Subject:   Re: cvs commit: src/lib/libc/gen popen.c 
Message-ID:  <199810110906.CAA02043@apollo.backplane.com>
References:   <199810110309.LAA18511@spinner.netplex.com.au>

next in thread | previous in thread | raw e-mail | index | archive | help
:Bruce Evans wrote:
:> bde         1998/10/10 12:30:45 PDT
:> 
:>   Modified files:
:>     lib/libc/gen         popen.c 
:>   Log:
:>   vfork -> fork.  The child calls execl() which calls malloc(), so
:>   vfork() can't be used.  We could use alloca() in execl() so that
:>   it can be called between vfork() and execve(), but a "portable"
:...
:
:Why not fix it properly by not using execl()?

    Wait a second!!!!!! vfork() was specifically designed for situations
    where you call the exec*() functions.  That's the whole point of 
    using vfork() rather then fork()!!!!!

    If execl() is not compatible with vfork(), then execl() is seriously
    broken.  And I do mean seriously.  I can't begin to count the number
    of times I use vfork()/execl() in programs.

    The problem ought to be easily solvable by having the exec*() functions
    cache the returned argv in a static and 'free' them on the following
    call before allocating a new copy, so the parent process does not
    leak memory.  Frankly, I'd prefer a solution that doesn't touch malloc
    at all... if it were me I'd just take &arg and be done with it, but
    alloca() is probably better then that.  Still not fun, but better.

					-Matt


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe cvs-all" in the body of the message



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199810110906.CAA02043>