Skip to content

Instantly share code, notes, and snippets.

@jhsu
Created November 10, 2011 21:25
Show Gist options
  • Save jhsu/1356284 to your computer and use it in GitHub Desktop.
Save jhsu/1356284 to your computer and use it in GitHub Desktop.
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