Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Linux] Properly raise ZombieProcess in exe() method #2062

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions psutil/_pslinux.py
Original file line number Diff line number Diff line change
Expand Up @@ -1741,16 +1741,16 @@ def exe(self):
try:
return readlink("%s/%s/exe" % (self._procfs_path, self.pid))
except (FileNotFoundError, ProcessLookupError):
# no such file error; might be raised also if the
# path actually exists for system processes with
# low pids (about 0-20)
if os.path.lexists("%s/%s" % (self._procfs_path, self.pid)):
return ""
if not pid_exists(self.pid):
raise NoSuchProcess(self.pid, self._name)
else:
if not pid_exists(self.pid):
raise NoSuchProcess(self.pid, self._name)
else:
# its /proc/pid directory exists, but the /exe file does not.
# it's either a zombie
if self.status() == "zombie":
raise ZombieProcess(self.pid, self._name, self._ppid)
else:
# or a kernel thread, for whom we return an empty string.
return ""
except PermissionError:
raise AccessDenied(self.pid, self._name)

Expand Down