Forking Win32 process?

Dmitry Bely
Mon Jan 28 08:28:00 GMT 2008

On Jan 28, 2008 12:36 AM, Igor Peshansky <> wrote:
> On Sun, 27 Jan 2008, Dmitry Bely wrote:
> > On Jan 27, 2008 5:15 PM, Christopher Faylor
> > <> wrote:
> > > Of course it is not impossible.  I doubt that anyone would be interested
> > > in implementing this however.  The main focus of the project is to make
> > > things work for the standard case of linking cygwin1.dll into a program
> > > and creating a "cygwin program".  Getting things like fork() working
> > > with MSVC or MinGW programs is not something that anyone really wants to
> > > do.
> >
> > Sometimes it's needed (as in my case :) but your point is taken. BTW,
> > I have seen in the archives that several years ago someone tried to
> > implement the native fork() via NT kernel call
> > NtCreateProcess()/ZwCreateProcess(). Did these efforts succeeded in
> > any way? Is there any working solution (performance is not a
> > question)?
> FYI, nothing prevents you from invoking CreateProcess from within the code
> even now.

CreateProcess and NtCreateProcess are not equal. The latter can do
copy-on-write and is used in the Windows' POSIX subsystem fork()
implementation. But using it is quite tricky. IIRC there are DLL
initialization issues. I just wanted to know if someone had finally
resolved them and proposed something that really worked.

> The call will not understand POSIX paths, and the resulting
> process may not show up in the Cygwin process table, *and* you will not be
> able to wait() for it in quite the same way, but pure Win32 calls are
> always accessible from Cygwin programs.  Unless you need the full POSIX
> fork functionality, the MinGW fork implementation should do just as well.

Yes, I just need to fully clone a native Win32 process. Thanks for
pointing to MinGW (probably you mean MSYS?), I will look into it.

- Dmitry Bely

More information about the Cygwin-developers mailing list