Sorry for the delay in the answer.
That's it!. I never thought MSDN was going to be my friend, but yes.
There is a rather good example in:

Thank you very much

2007/7/30, <>:
Jonathan Wilson wrote, quoting Luis Ramirez:
> > Do you know which #includes and libs are needed to include for these pipe,
> > fork, dup2 and exec functions, or other similar functions.
> Windows does not include a fork function. You will either need to rewrite
> your code to call windows specific process related functions such as
> CreateProcess ...

As Tuomo said, in another reply, MSDN is your friend.  So is our mailing list archive, for this question has already been answered several times before.

To replace pipe(), you may use Microsnot's _pipe(), but it isn't a direct replacement; you need to deal with different semantics.

The most direct replacement for fork()...exec??() is _spawn??(); it passes the argument list, just like exec??() does, through to CreateProcess(), but there are a couple of gotchas:

1) You have to save the parent's I/O context, and set up the I/O context for the child, within the *parent*; there is no opportunity for the child to set up its I/O context for itself, as you can do between fork() and exec??() in *nix.  Then, after spawning the child, the parent must restore its own I/O context.

2) Microsnot's _spawn??() and _exec??() functions are all broken, WRT grouping of arguments containing embedded white space.  To get around that, GPL programs may use our `execwrap' library:

If you can't, or won't use GPL, then you may not use that; you'll have to deal with building a properly quoted argument string, to pass to CreateProcess(), for yourself.


Email sent from
Virus-checked using McAfee(R) Software and scanned for spam

This email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>
MinGW-users mailing list

You may change your MinGW Account Options or unsubscribe at: