Skip to content

Commit

Permalink
fix(utils/process): don't fail when we don't get access to a process'…
Browse files Browse the repository at this point in the history
…s cwd
  • Loading branch information
aravinda0 committed Nov 20, 2023
1 parent 418f69f commit 3feb9e8
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/qtile_bonsai/utils/process.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# SPDX-FileCopyrightText: 2023-present Aravinda Rao <maniacalace@gmail.com>
# SPDX-License-Identifier: MIT

from psutil import Process
from psutil import Process, AccessDenied


def modify_terminal_cmd_with_cwd(cmd: str, parent_pid: int) -> str:
Expand Down Expand Up @@ -31,7 +31,11 @@ def modify_terminal_cmd_with_cwd(cmd: str, parent_pid: int) -> str:
if switch not in cmd_frags:
parent_proc = Process(parent_pid)
cwd_ref_proc = find_deepest_shell_process(parent_proc) or parent_proc
return f"{cmd} {switch} {cwd_ref_proc.cwd()}"
try:
cwd = cwd_ref_proc.cwd()
except AccessDenied:
return cmd
return f"{cmd} {switch} {cwd}"

return cmd

Expand Down

0 comments on commit 3feb9e8

Please sign in to comment.