Created
November 10, 2011 21:25
-
-
Save jhsu/1356284 to your computer and use it in GitHub Desktop.
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
puts $$ | |
children = [] | |
list = [1,2] | |
list.each do |i| | |
pid = fork { | |
puts i | |
loop do | |
print '.' | |
sleep 0.5 | |
end | |
} | |
Process.detach(pid) | |
children << pid | |
end | |
trap("INT") { | |
children.each {|i| Process.kill("INT", i) } | |
exit | |
} | |
list = nil | |
Process.waitall |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment