File tree Expand file tree Collapse file tree 1 file changed +11
-0
lines changed Expand file tree Collapse file tree 1 file changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -244,6 +244,17 @@ func (t *TmuxSession) Attach() (chan struct{}, error) {
244
244
go func () {
245
245
defer t .wg .Done ()
246
246
_ , _ = io .Copy (os .Stdout , t .ptmx )
247
+ // When io.Copy returns, it means the connection was closed
248
+ // This could be due to normal detach or Ctrl-D
249
+ // Check if the context is done to determine if it was a normal detach
250
+ select {
251
+ case <- t .ctx .Done ():
252
+ // Normal detach, do nothing
253
+ default :
254
+ // If context is not done, it was likely an abnormal termination (Ctrl-D)
255
+ // Print warning message
256
+ fmt .Fprintf (os .Stderr , "\n \033 [31mError: Session terminated without detaching. Use Ctrl-Q to properly detach from tmux sessions.\033 [0m\n " )
257
+ }
247
258
}()
248
259
249
260
go func () {
You can’t perform that action at this time.
0 commit comments