Subject: Re: ming exec forks ???
From: Earnie Boyd <[email-masked]>
To: Keraba <[email-masked]>
Cc: [email-masked]
Date: Thu, 2 Dec 1999 19:32:18 -0800 (PST)

--- Mumit Khan <[email-masked]> wrote:
> Keraba <[email-masked]> writes:
> > Hi,
> > 
> > I'm having trouble with the execv() system call. With the Cygwin
> > gcc and libraries it works fine, but with the Ming equivalents
> > it acts more like fork(), spawning off a child then continuing,
> > without waiting for the child to die first.
> 
> I don't know what the problem is, but under windows, you probably
> want _spawnv[pe] instead. Go to MS web site and search the docs
> -- it's all online.
> 

Typically in UNIX your code would fork() and you would set the child process to
execv() and you set the parent process to wait on the child.  In both unix and
win32 the execv() function replaces the current process with that which is
called so that you no longer have the calling process only the called process. 

When you fork you actually are starting another process of the same binary with
a copy of all of the variables in tact.  The fork in the second process returns
with a value of zero to indicate that this is the child process. The fork in
the first process returns the value of the process id created for the second
process and you then know to wait on the child.

The _spawnv[pe] function differs from the fork function in that it doesn't
create a copy of the current process.  Instead, the created process is used to
execute the process passed in the arguments and you tell it to either WAIT or
NO_WAIT.  If you NO_WAIT, it will return the created process id.  If you WAIT
it will return either zero or non-zero to indicate a valid completion.

Hope this helps,

=====
Earnie Boyd <mailto:[email-masked]>
Cygwin Newbies, please visit
<http://www.freeyellow.com/members5/gw32/index.html>
__________________________________________________
Do You Yahoo!?
Thousands of Stores.  Millions of Products.  All in one place.
Yahoo! Shopping: http://shopping.yahoo.com

--
Want to unsubscribe from this list?
Send a message to [email-masked]