Skip to content

Commit

Permalink
fix open_files
Browse files Browse the repository at this point in the history
  • Loading branch information
giampaolo committed Oct 14, 2024
1 parent 3e5f30b commit 0b93503
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions psutil/_psbsd.py
Original file line number Diff line number Diff line change
Expand Up @@ -911,7 +911,14 @@ def _not_implemented(self):
@wrap_exceptions
def open_files(self):
"""Return files opened by process as a list of namedtuples."""
rawlist = cext.proc_open_files(self.pid)
if OPENBSD and self.pid == 0:
try:
rawlist = cext.proc_open_files(self.pid)
except ProcessLookupError:
return []
else:
rawlist = cext.proc_open_files(self.pid)

return [_common.popenfile(path, fd) for path, fd in rawlist]

else:
Expand All @@ -930,9 +937,7 @@ def num_fds(self):
except ProcessLookupError:
return 0
elif NETBSD:
ret = cext.proc_num_fds(self.pid)
self._assert_alive()
return ret

return cext.proc_num_fds(self.pid)

Expand Down

0 comments on commit 0b93503

Please sign in to comment.