7

On Unix to Windows Porting Dictionary for HPC page for fork() it's written

There is no equivalent Windows API to the Unix fork() or vfork(). The Microsoft Subsystem for Unix-based Applications (SUA or Interix) is a Unix environment that has fork() and vfork() properly implemented.

and further on the page there's example source code which uses... standard Win32 API CreateProcess function.

I'm confused.
Shouldn't the example use fork() to illustrate the statement about fork() being implemented by SUA/Interix?
If fork() is really implemented which header and lib files does it live in?

Piotr Dobrogost
  • 41,292
  • 40
  • 236
  • 366
  • 2
    Related questions: [What is the closest thing windows has to fork()?](http://stackoverflow.com/questions/985281/), [substitute for fork()ing? in windows.](http://stackoverflow.com/questions/4243880/), [CreateThread vs fork()](http://stackoverflow.com/questions/619019/), [fork/chroot equivalent for Windows server application](http://stackoverflow.com/questions/1686578/), [Where does Microsoft Windows 7 POSIX implementation currently stands?](http://stackoverflow.com/questions/4746043/) – Piotr Dobrogost Mar 20 '11 at 22:21

1 Answers1

4

The page you're looking at is the *nix to Windows porting guide. It doesn't show you how to use fork() but the closest win32 equivialent, CreateProcess. The pages there documents which Win32 function you should use instead of Unix functions.

You'll need the subsystem for Unix and the SUA SDK to use fork(). There you'll get a *nix environment on Windows, fork() will be in the usual unistd.h library, and you'll link to libc.so (using gcc) to use it.

Ajay
  • 18,086
  • 12
  • 59
  • 105
nos
  • 223,662
  • 58
  • 417
  • 506
  • Are there any online docs for this SDK listing available functions the same way MSDN lists Win32 API functions? I know there are plenty docs for POSIX but I'm curious if there's online documentation for this particular SDK? – Piotr Dobrogost Mar 20 '11 at 21:47
  • 1
    @PiotrDobrogost: The only documentation I've seen is [here](http://technet.microsoft.com/en-us/library/cc754234.aspx), which is pretty much nothing. – user541686 Apr 22 '12 at 01:09