Skip to content

Conversation

@un-def
Copy link
Collaborator

@un-def un-def commented Nov 20, 2025

When error logging was added to SSHTunnel.close()1, it was discovered that SSHAttach.detach() is called multiple times on detach. Although this is harmless as long as this method is idempotent (and it is), this patch ensures that detach() is no-op when called more than one time, removing ERROR level log noise.

As a side-effect, detaching SSHAttach that reuses SSHTunnel no longer kills "master" SSHAttach, meaning that one can dstack attach multiple times and detach independently (detaching from the "master" attach still kicks out all other attaches).

When error logging was added to SSHTunnel.close()[1], it was discovered
that SSHAttach.detach() is called multiple times on detach.
Although this is harmless as long as this method is idempotent (and it is),
this patch ensures that detach() is no-op when called more than one
time, removing ERROR level log noise.

As a side-effect, detaching SSHAttach that reuses SSHTunnel no longer
kills "master" SSHAttach, meaning that one can `dstack attach` multiple
times and detach independently (detaching from the "master" attach still
kicks out all other attaches).

[1]: #3296
start_new_session is POSIX-only (ignored on Windows),
and Windows-specific CREATE_NEW_PROCESS_GROUP flag doesn't work as
expected (it seems that ssh still receives CTRL_C_EVENT, at least it
exits immediately on Ctrl+C event).
@un-def un-def merged commit 5bb7e6f into master Nov 21, 2025
28 checks passed
@un-def un-def deleted the pr_fix_sshattach_detach branch November 21, 2025 05:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants