Try to rescue from SystemCallError
rescue SystemCallError => e
Question
I want to rescue "Operation not permitted" when killing a process but I don`t know how!
def kill(process)
process.each do |line|
if line.include? "java"
process_no = line.split[0]
`kill -9 #{process_no}`
end
end
end
while true
retry_count += 1
# check if tomcat is alive!
tomcat = `ps axf | grep tomcat`
process = tomcat.split(/\n/)
if checkPID(process)
print "."
if retry_count < 3
print "."
else
puts " try to kill.."
begin #=>=(((it doesn't work
kill(process)
rescue Exception => e
puts("")
break
end #=> =((((
end
I`m cheking it in the while loop but it doesn't work.
Solution
Try to rescue from SystemCallError
rescue SystemCallError => e