Last active
November 22, 2020 04:02
-
-
Save felipec/7303244 to your computer and use it in GitHub Desktop.
Display a list of all the processes listed by their autogroup (CONFIG_SCHED_AUTOGROUP)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
$autogroups = Hash.new { |h,k| h[k] = [] } | |
Dir.glob('/proc/*').each do |e| | |
pid = File.basename(e).to_i | |
next if pid == 0 | |
begin | |
cmdline = File.read(e + '/cmdline').split("\0").join(" ") | |
next if cmdline.empty? | |
if File.read(e + '/autogroup') =~ %r{^/autogroup-(\d+)} | |
autogroup = $1.to_i | |
else | |
autogroup = nil | |
end | |
$autogroups[autogroup] << [pid, cmdline] | |
rescue Errno::ENOENT | |
next | |
end | |
end | |
$autogroups.values.each do |e| | |
puts '-' * 80 | |
e.each { |cmd| puts "%s\t%s" % cmd } | |
end | |
puts '-' * 80 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment