Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

show file descriptors using lsof when killing processes.

  • Loading branch information...
commit 04463c422294adebe4047ba6b4e4060b2459a29b 1 parent 01d6356
@akr authored
Showing with 20 additions and 1 deletion.
  1. +20 −1 timeoutcom.rb
View
21 timeoutcom.rb
@@ -111,12 +111,31 @@ def show_process_group(pgid, msgout)
psresult = psio.to_a
pat = /\A\s*#{pgid}\b/
first = true
+ pids = []
psresult.each {|line|
- if first || pat =~ line
+ if first
msgout.puts "PSOUT #{line}"
+ elsif pat =~ line
+ msgout.puts "PSOUT #{line}"
+ if /\A\s*\d+\s+(\d+)/ =~ line
+ pids << $1
+ end
end
first = false
}
+ if !pids.empty?
+ lsof_command = "lsof -p #{pids.join(',')}"
+ begin
+ lsofresult = `#{lsof_command}`
+ rescue Errno::ENOENT
+ lsofresult = nil
+ end
+ if lsofresult
+ lsofresult.each_line {|line|
+ msgout.puts "LSOFOUT #{line}"
+ }
+ end
+ end
}
end
Please sign in to comment.
Something went wrong with that request. Please try again.