forking() and CreateProcess()

Sunny picture Sunny · Dec 12, 2012 · Viewed 11.2k times · Source

Are forking() and CreateProcess(with all required arguments), the same thing for Linux and WinXP, respectively?

If they are different, then could someone explain the difference in terms of what happens in each of the two cases?

Thanks

Answer

Some programmer dude picture Some programmer dude · Dec 12, 2012

They do different things, and on different systems. CreateProcess is a Windows-only function, while fork is only on POSIX (e.g. Linux and Mac OSX) systems.

The fork system call creates a new process and continue execution in both the parent and the child from the point where the fork function was called. CreateProcess creates a new process and load a program from disk. The only similarity is that the end result is a new process is created.

For more information, read the respective manual page on CreateProcess and fork.