-
Notifications
You must be signed in to change notification settings - Fork 9
Open
Labels
enhancementNew feature or requestNew feature or request
Description
I asked our friends from ChatGPT for a robust check.
It suggested the following:
import os
import subprocess
def parent_process_name():
ppid = os.getppid()
try:
return subprocess.check_output(
["ps", "-p", str(ppid), "-o", "comm="],
text=True
).strip()
except Exception:
return None
parent = parent_process_name()
print(parent) # likely "pwsh"os.getppid should also be available on Windows. I am not so sure about ps. Depending on the availability of ps on Windows, this check can also be used on Windows, otherwise only on unix systems.
update: It is not available on Windows.
I think this is an improvement compared to the current heuristics.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request