From: Martin DeMello Date: 2009-04-04T19:06:00+09:00 Subject: Re: Kill a process by name and PID - needs refinement On Sat, Apr 4, 2009 at 3:19 PM, sanjayayogi wrote: > This works pretty well but does not ask you for confirmation before > you clobber a process > Any other improvements welcome. IDEAS? It uses kill -9, probably not > the best idea... As a matter of style, you should separate out the part of your program that does the actual work from the part that does the input/output. Structure it more like def get_pid_from_name(process_name) #... end def kill_process(pid, signal) #... end # main program starts here print "enter process name" pname = gets.chomp() print "enter signal" signal = gets.chomp() pid = get_pid_from_name(pname) kill_process(pid, signal) martin