Last active
October 14, 2019 10:31
-
-
Save seki/0816f51977eb58327ecb01885696408b to your computer and use it in GitHub Desktop.
close on fork
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'drb' | |
def test_fd | |
sleeper = DRbObject.new_with_uri('druby://localhost:50097') | |
ary = 20.times.collect { | |
Thread.new { sleeper.sleep(5) } | |
} | |
ary.each {|th| th.join} | |
system("lsof -p #{$$} | wc -l") | |
fork { | |
system("lsof -p #{$$} | wc -l") | |
GC.start # close on fork and GC (new one) | |
system("lsof -p #{$$} | wc -l") | |
sleeper.sleep(0.1) # close on dRuby call. (PR Fix some DRb issues #2552) | |
system("lsof -p #{$$} | wc -l") | |
} | |
end | |
test_fd | |
gets | |
test_fd | |
gets |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'drb' | |
class Sleeper | |
def sleep(n) | |
puts "sleeping: #{n}" | |
Kernel.sleep(n) | |
end | |
end | |
DRb.start_service('druby://localhost:50097', Sleeper.new) | |
gets |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment