forked from espressif/esp-idf
fix(activate): use exe instead of comm for parent shell detection
Currently, we are using psutil.Process().name(), which includes the command as entered on the command line. This becomes an issue if the export script is initiated within another script. run.sh #!/usr/bin/bash . ./export.sh In this case the activate script will see `run.sh` instead of bash. /proc/<pid>/com vs /proc/<pid>/exe Use exe(), which contains the full executable path to fix this. Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
This commit is contained in:
@@ -107,7 +107,7 @@ def detect_shell(args: Any) -> str:
|
||||
detected_shell_name = ''
|
||||
while True:
|
||||
parent_pid = psutil.Process(current_pid).ppid()
|
||||
parent_name = psutil.Process(parent_pid).name()
|
||||
parent_name = os.path.basename(psutil.Process(parent_pid).exe())
|
||||
if not parent_name.lower().startswith('python'):
|
||||
detected_shell_name = parent_name
|
||||
conf.DETECTED_SHELL_PATH = psutil.Process(parent_pid).exe()
|
||||
|
Reference in New Issue
Block a user