运行fork(2)从Windows与Cygwin。可能?
我想使用一个名为shotgun的ruby gem,需要fork(2)命令,我发现它是一个Linux命令,可能在Cygwin中可用。是否可以通过Windows命令shell使其可用?
I am trying to use a Ruby gem called shotgun that requires fork(2) command which I discovered is aa Linux command, and might be available in Cygwin. Is it possible to make it available through Windows command shell?
fork(2)
是cygwin下的kludgey,过程模型不容易允许它发生。 Cygwin可能允许它的产生使用它,但是你会遭受严重的性能打击,因为Cygwin必须手动模拟一切 - 包括复制可执行数据,复制打开的句柄等。
fork(2)
is kludgey under Cygwin, as the Windows process model does not easily allow it to happen. Cygwin may allow its spawn to use it, but you're going to suffer a serious performance hit as Cygwin has to emulate everything by hand -- including copying the executable data, copying the open handles, etc.
根据猎枪使用 fork(2)
的多少,这种模拟可能会很痛苦,或者可能相对较小。
Depending on how much shotgun uses fork(2)
, this emulation could be painful or it could be relatively minor.
以下是GameDev.net上的好主题讨论在Win32上缺少 fork
工具。他们提出了一些我没有耐心或平台无法进行调查,但肯定听起来有趣,危险和爆炸性的同时:
Here's a good thread on GameDev.net discussing the lack of a fork
facility on Win32. They bring up something which I don't have the patience or platform accessibility to investigate, but certainly sounds fun, dangerous, and explosive all at the same time:
所以,你需要绕过Win32并调用本机API({Nt | Zw} CreateProcess)。本书Windows Nt / 2000本机Api参考有一个例子分叉Win32进程。这可能是你需要的。
So, you need to bypass Win32 and call the native API ({Nt|Zw}CreateProcess). The book "Windows Nt/2000 Native Api Reference" has an example "Forking a Win32 Process". This may be what you need.
我很感兴趣,但我怀疑Cygwin使用它。它可能在那里,重申我的回答你的问题 - 很多Unix应用程序依赖 fork
,Cygwin可能使它可用。只是不要指望奇迹,你必须让Ruby意识到Cygwin,通过重新编译它包括它的仿真层。
I'm intrigued, but I doubt Cygwin uses it. It's probably there, to reiterate my answer to your question -- a lot of Unix apps rely on fork
, and Cygwin likely makes it available. Just don't expect miracles, and you'll have to make Ruby aware of Cygwin by recompiling it to include its emulation layer.