在 MRI Ruby 中,我可以这样做:
def transfer
internal_server = self.init_server
pid = fork do
internal_server.run
end
# Make the server process run independently.
Process.detach(pid)
internal_client = self.init_client
# Do other stuff with connecting to internal_server...
internal_client.post('some data')
ensure
# Kill server
Process.kill('KILL', pid) if pid
end
但是上面的代码不会在 jRuby 中运行,因为它不支持 'fork' 方法:
NotImplementedError: fork is not available on this platform
在 jRuby 中是否有任何替代解决方案?
谢谢。