0

我想在杀死进程时挽救“不允许操作”,但我不知道如何!

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

我在 while 循环中检查它,但它不起作用。

4

1 回答 1

0

尝试从SystemCallError

rescue SystemCallError => e
于 2013-10-12T14:57:35.007 回答