Skip to content

Commit

Permalink
Detect powershell. Take 2.
Browse files Browse the repository at this point in the history
  • Loading branch information
Oluwatosin Adewale committed Apr 2, 2019
1 parent a840d12 commit 045eede
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -377,8 +377,10 @@ def _get_parent_proc_name():
parent = psutil.Process(os.getpid()).parent()
if parent:
# powershell.exe launches cmd.exe to launch the cli.
if parent.parent() and parent.name().lower().startswith("powershell"):
return parent.parent().name()
grandparent = parent.parent()
if grandparent and grandparent.name().lower().startswith("powershell"):
return grandparent.name()
# if powershell is not the grandparent, simply return the parent's name.
return parent.name()
return None

Expand Down

0 comments on commit 045eede

Please sign in to comment.