Are there sigkills for streams?

My guess is that some threads might not want to die.

t = Thread.new { begin
                    puts 'do'
                    sleep 10
                    puts 'done'
                 ensure
                    loop { puts "really don't wanna die" }
                 end
               }

      

^ Imagine what happens if you try Thread#kill

this pesky bastard.

+3


source to share


2 answers


t.exit
t.alive? => false

      



if you are using traps you should read about trap("EXIT")

0


source


If you are asking how to kill a process, you can simply do

Process.kill("KILL", pid)

      

Once it gets kill -9, the kernel then kills the process itself. killing the thread with it. also, you can capture this signal and kill it gracefully



Signal.trap("KILL")  { puts "Child died" }

      

Does this answer your question?

-1


source







All Articles