Skip to content

Commit

Permalink
work around for pid 0
Browse files Browse the repository at this point in the history
  • Loading branch information
giampaolo committed Oct 14, 2024
1 parent 023d325 commit 3e5f30b
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions psutil/_psbsd.py
Original file line number Diff line number Diff line change
Expand Up @@ -924,10 +924,17 @@ def open_files(self):
@wrap_exceptions
def num_fds(self):
"""Return the number of file descriptors opened by this process."""
ret = cext.proc_num_fds(self.pid)
if NETBSD or OPENBSD:
if OPENBSD and self.pid == 0:
try:
return cext.proc_num_fds(self.pid)
except ProcessLookupError:
return 0
elif NETBSD:
ret = cext.proc_num_fds(self.pid)
self._assert_alive()
return ret
return ret

return cext.proc_num_fds(self.pid)

else:
num_fds = _not_implemented
Expand Down

0 comments on commit 3e5f30b

Please sign in to comment.