Martin DeMello
4/4/2009 10:06:00 AM
On Sat, Apr 4, 2009 at 3:19 PM, sanjayayogi <sanjaya.yogi@gmail.com> 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