In POSIX, there is the fork()
function to create a sub-process. How can I achieve fork()
's functionality in Windows?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
There is no direct equivalent of fork()
on Windows.
CreateProcess()
is the native function that can be used to create a new process (but, again, the semantics are rather different to fork()
's).
To put this another way, on Unix it is possible for a process to cheaply create a clone of itself. There is no inexpensive way to do this on Windows.
If you don't care about the cloning aspect of fork()
, then CreateProcess()
should do just fine.