Skip to content

Commit

Permalink
use ps command instead of pgrep on linux
Browse files Browse the repository at this point in the history
  • Loading branch information
TTianshun committed Dec 14, 2023
1 parent 79f7df5 commit df42ecf
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions src/viztracer/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,7 @@ def get_subprocess_pid_recursive(pid: int) -> set:
def get_subprocess_pid(pid: int) -> set:
if sys.platform == "win32":
cmdline = f"wmic process where (ParentProcessId={pid}) get ProcessId"
elif sys.platform in ("linux", "linux2"):
cmdline = f"pgrep -P {pid}"
elif sys.platform == "darwin":
else:
cmdline = f"ps -o pid,ppid -ax | awk \'{{ if ( $2 == {pid} ) {{ print $1 }} }}'"
result = subprocess.run(cmdline, stdout=subprocess.PIPE, stderr=subprocess.PIPE, timeout=1)
lines = result.stdout.decode("utf-8").splitlines()
Expand Down

0 comments on commit df42ecf

Please sign in to comment.