Skip to content

Commit

Permalink
linux: process: Remove zombie check (fixed in psutil)
Browse files Browse the repository at this point in the history
  • Loading branch information
d3dave committed Feb 26, 2024
1 parent d1c38a0 commit 66392c8
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions granulate_utils/linux/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,12 @@

def process_exe(process: psutil.Process) -> str:
"""
psutil.Process(pid).exe() returns "" for zombie processes, incorrectly. It should raise ZombieProcess, and return ""
only for kernel threads.
See https://github.com/giampaolo/psutil/pull/2062
psutil.Process(pid).exe() caches the result. This function returns the up-to-date exe in case the process exec-ed.
"""
# Clear the "exe" cache on the process object. It can change after being cached if the process execed.
# Clear the "exe" cache on the process object
process._exe = None # type: ignore
exe = process.exe()
if exe == "":
if is_process_zombie(process):
raise psutil.ZombieProcess(process.pid)
raise MissingExePath(process)
return exe

Expand Down

0 comments on commit 66392c8

Please sign in to comment.