Skip to content

Commit

Permalink
fixing bpflist
Browse files Browse the repository at this point in the history
when you have lots of shortlived progs, there is posibillity of
race condition during proc scanning. you could get pid of this
shortlived prog, but when you will start to read it's fd/ dir
it will fail, as prog would be already terminated
  • Loading branch information
tehnerd committed Apr 18, 2018
1 parent f4e1c33 commit 98ee5df
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions tools/bpflist.py
Expand Up @@ -72,8 +72,10 @@ def find_bpf_fds(pid):

for pdir in os.listdir('/proc'):
if re.match('\\d+', pdir):
find_bpf_fds(int(pdir))

try:
find_bpf_fds(int(pdir))
except OSError:
continue
print("%-6s %-16s %-8s %s" % ("PID", "COMM", "TYPE", "COUNT"))
for (pid, typ), count in sorted(counts.items(), key=lambda t: t[0][0]):
comm = comm_for_pid(pid)
Expand Down

0 comments on commit 98ee5df

Please sign in to comment.