Skip to content

Instantly share code, notes, and snippets.

@emboss
Created January 29, 2015 09:56
Show Gist options
  • Save emboss/506f0976c7a46068b35a to your computer and use it in GitHub Desktop.
Save emboss/506f0976c7a46068b35a to your computer and use it in GitHub Desktop.
Kill thread that spawned a process
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