Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

fork() in windows

257 views
Skip to first unread message

sridharn

unread,
Apr 28, 2009, 1:28:41 PM4/28/09
to
Hi,
I am looking for a windows function similar to UNIX fork() in
windows. I do realise that CreateProcess creates a new process but
mandates the input for a module name.I need a function that creates a
process and allows me to continue coding the parent process and the
child process in the same source file.It could have a call back
function that would be invoked once a child process is created
(similar to AFxBeginThread ).


Thanks,
Sridhar.

Kornél Pál

unread,
Apr 28, 2009, 1:41:20 PM4/28/09
to
Hi,

NtCreateProcess is capable of doing this but I've never tried that.
Since a lot of work is done in CreateProces and NtCreateProcess is a
very low level function you may need to emulate CreateProcess
functinality like informing CSRSS about the new process.

Libraries designed to work with the Win32 subsystem my also have
problems with that.

As far as I know the Unix subsystem is using NtCreateProcess for fork to
duplicate the address space but creates a new process (native NT
process) without address space duplication form exec.

Cygwin on the other hand is using CreateProcess and uses it's own logic
to load DLLs. Note that that solution is reportedly incompatible with
DLL relocation and address space randomization.

Korn�l

Don Burn

unread,
Apr 28, 2009, 1:57:47 PM4/28/09
to
I've seen a number of attempts in the kernel and the user space for this,
but bottom line is you are reproducing a ton of the undocumented Windows
code and needing to do it perfectly. If you want fork use one of the Unix
environments for Windows and accept all of their restrictions, or else
develop your software to follow a windows model.


--
Don Burn (MVP, Windows DDK)
Windows Filesystem and Driver Consulting
Website: http://www.windrvr.com
Blog: http://msmvps.com/blogs/WinDrvr
Remove StopSpam to reply

"Korn�l P�l" <korn...@newsgroup.nospam> wrote in message
news:enNINiCy...@TK2MSFTNGP06.phx.gbl...

> __________ Information from ESET NOD32 Antivirus, version of virus
> signature database 4040 (20090428) __________
>
> The message was checked by ESET NOD32 Antivirus.
>
> http://www.eset.com
>
>
>

__________ Information from ESET NOD32 Antivirus, version of virus signature database 4040 (20090428) __________

The message was checked by ESET NOD32 Antivirus.

http://www.eset.com


Tim Roberts

unread,
Apr 29, 2009, 12:11:09 AM4/29/09
to

You can certainly download the source code for Cygwin and see how they
implemented it.

If it were me, however, I would be focusing my attention on ways to
rearchitect the application so that it uses threads instead of processes.
--
Tim Roberts, ti...@probo.com
Providenza & Boekelheide, Inc.

sridharn

unread,
Apr 29, 2009, 5:03:34 PM4/29/09
to
On Apr 28, 9:11 pm, Tim Roberts <t...@probo.com> wrote:
> Tim Roberts, t...@probo.com
> Providenza & Boekelheide, Inc.

Thanks everyone for your suggestions. I think I may try to look for
an alternative solution for re-structuring my program rather than
creating a process.

Thanks,
Sridhar.

0 new messages