Search code examples
forkcreateprocess

forking() and CreateProcess()


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


Solution

  • 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.


    To summarize: CreateProcess is similar to fork() followed by one of the exec() functions.