Skip to content

Instantly share code, notes, and snippets.

@phiggins
Created December 6, 2010 16:55
Show Gist options
  • Save phiggins/730563 to your computer and use it in GitHub Desktop.
Save phiggins/730563 to your computer and use it in GitHub Desktop.
DeferrableChildProcess
require 'eventmachine'
# Code adapted from EM's tests:
# https://github.com/eventmachine/eventmachine/blob/master/tests/test_processes.rb#L43
ls = ""
EM.run {
d = EM::DeferrableChildProcess.open( "ruby -v" )
d.callback {|data_from_child|
ls = data_from_child
EM.stop
}
}
puts ls
# linux
# $ ruby -Ilib test_processes.rb
# ruby 1.9.2p0 (2010-08-18 revision 29036) [x86_64-linux]
# winxp
# >ruby -Ilib test_processes.rb
# terminate called after throwing an instance of 'std::runtime_error'
# what(): socketpair is currently unavailable on this platform
#
# This application has requested the Runtime to terminate it in an unusual way.
# Please contact the application's support team for more information.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment