Created
January 29, 2015 09:56
-
-
Save emboss/506f0976c7a46068b35a to your computer and use it in GitHub Desktop.
Kill thread that spawned a process
This file contains hidden or 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
t = Thread.new do | |
pid = Process.fork do | |
loop do | |
puts "Hi" | |
sleep 0.5 | |
end | |
end | |
puts "Use 'kill -9 #{pid}' to kill me!" | |
Process.wait pid | |
end | |
sleep 2 | |
t.kill | |
# And it keeps running... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment