Skip to content

Commit d2b8780

Browse files
committed
ControlMode(core,test): Attach preflight and stabilize control flag/capture checks
1 parent 065db68 commit d2b8780

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/libtmux/_internal/engines/control_mode.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,23 @@ def _start_process(self, server_args: tuple[str | int, ...]) -> None:
296296

297297
# Build command based on configuration
298298
if self._attach_to:
299+
# Fail fast if attach target is missing before starting control mode.
300+
has_session_cmd = [
301+
tmux_bin,
302+
*[str(a) for a in server_args],
303+
"has-session",
304+
"-t",
305+
self._attach_to,
306+
]
307+
probe = subprocess.run(
308+
has_session_cmd,
309+
capture_output=True,
310+
text=True,
311+
)
312+
if probe.returncode != 0:
313+
msg = f"attach_to session not found: {self._attach_to}"
314+
raise exc.ControlModeConnectionError(msg)
315+
299316
# Attach to existing session (advanced mode)
300317
cmd = [
301318
tmux_bin,

0 commit comments

Comments
 (0)