kill_pid.rb - kill a process by a given name
Written by [email protected]
This code first asks you the name of the process you want to kill -
respond with the name of the process
It will return the pid - if you you only want the pid comment out
the final line:
ie: #exec killall_pid
puts " Hello, what PID do you want? "
process = gets.chomp
a = process
b = “‘ps -C " + a + " -o pid=’”
D = “IO.popen(” + b + “, ‘r+’) do |pipe|”
str = D + “\n” + “pipe.close_write” + “\n” + “puts pipe.read” + “\n” +
x = D + “\n” + “pipe.close_write” + “\n” + “puts pipe.read” + “\n” +
kill = "kill -9 "
killall -i makes the code interactive
killall_pid = "killall -i " + a
kills the process by name - not pid (does not seem to work with all
processes - I think
it would be better written to kill the process by pid instead but I
do not know how to
take the out put of eval pid and use the kill -9 command with the
pid IDEAS ANYONE?