Skip to content

Commit 0504d1b

Browse files
committed
fix(builder[here]): Warn when respawn-pane will kill running processes
Before calling respawn-pane -k, check pgrep -P <pane_pid> for child processes. If the shell has running children (background jobs, foreground programs), log a WARNING so users know their processes will be terminated. Gracefully handles missing pgrep.
1 parent f5f490a commit 0504d1b

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

src/tmuxp/workspace/builder.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import os
77
import shlex
88
import shutil
9+
import subprocess
910
import time
1011
import typing as t
1112

@@ -719,6 +720,26 @@ def iter_create_windows(
719720
if start_directory or environment or window_shell:
720721
_here_pane = window.active_pane
721722
if _here_pane is not None:
723+
# Warn if the pane has running child processes
724+
# that would be killed by respawn-pane -k
725+
_pane_pid = _here_pane.pane_pid
726+
if _pane_pid:
727+
try:
728+
_children = subprocess.run(
729+
["pgrep", "-P", _pane_pid],
730+
capture_output=True,
731+
text=True,
732+
)
733+
if _children.returncode == 0:
734+
logger.warning(
735+
"--here will kill running processes "
736+
"in the active pane (pid %s) to "
737+
"provision directory/environment",
738+
_pane_pid,
739+
)
740+
except FileNotFoundError:
741+
pass # pgrep not available
742+
722743
_respawn_args: list[str] = ["respawn-pane", "-k"]
723744
if start_directory:
724745
_respawn_args.extend(["-c", start_directory])

0 commit comments

Comments
 (0)