-
-
Notifications
You must be signed in to change notification settings - Fork 943
Closed
Milestone
Description
I am not sure this is an issue or there is something wrong in my following code:
# To mimic the Process.fork in MRI Ruby
module JRubyProcess
require 'ffi'
extend FFI::Library
ffi_lib FFI::Library::LIBC
attach_function :fork, [], :int
end
def transfer
internal_server = self.init_server
pid = JRubyProcess.fork do
internal_server.run
end
# Make the server process run indepently.
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
endMy tending is to run the internal server in another Ruby interpreter then I can kill the server process.
The 'transfer' method worked well in MRI Ruby. In JRuby, however, it will raise an exception when it runs to 'Process.detach(pid)':
Java::JavaLang::RuntimeException: CallBlock does not have a static scope; this should not be called
from org.jruby.runtime.CallBlock.getStaticScope(CallBlock.java:107)
from org.jruby.RubyProc.setup(RubyProc.java:159)
from org.jruby.RubyProc.newProc(RubyProc.java:118)
from org.jruby.RubyProc.newProc(RubyProc.java:113)
from org.jruby.Ruby.newProc(Ruby.java:2936)
from org.jruby.internal.runtime.RubyRunnable.<init>(RubyRunnable.java:60)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels