Open nicholas-ochoa opened 4 years ago
So! Pane teardown and tab teardown follow the same path for terminating a connection, unless the tab being closed is the last one. If it's the last one, the console host gets terminated before the application does and it becomes rather upset. Is it your last tab?
No - when I was testing I had multiple tabs open and was just adding a new tab, connecting to SSH, then closing that new tab via middle mouse click or clicking on the X.
It sounds like it's still taking a different path somehow, since the behavior does differ slightly.
Hey so this question's been open for a while now, but I concur, both actions should be following the same path. This was nearly 2 years ago now, so it's possible that we were leaking a control in one path but not the other, but at this point, that certainly shouldn't be the case anymore.
@nicholas-ochoa you still seeing this?
I ran through some additional scenarios and found more discrepencies. This was on Windows Terminal Preview version: 1.12.2931.0.
For each scenario with Windows Terminal, I am opening a Bash (git for windows) shell, then executing ssh user@server
and running my app.
Single tab open:
SIGHUP
SIGUSR1
Close Tab
: SIGHUP
Close Pane
: SIGHUP
Close Window
: SIGHUP
Close Tab
: SIGUSR1
Close Pane
: SIGHUP
Close Window
: SIGHUP
SIGHUP
SIGHUP
Two tabs open:
SIGHUP
.SIGHUP
Close Tab
: SIGUSR1
Close Pane
: SIGHUP
Close Window
: SIGUSR1
Close Tab
: SIGHUP
Close Pane
: SIGUSR1
Close Window
: SIGHUP
SIGUSR1
SIGHUP
For comparison, using Putty:
SIGUSR1
SIGHUP
well that's wild. I Have no idea why those would be different. I ESPECIALLY don't know why "Use hotkey to run Close Tab
" would be different from "Open command palette and select Close Tab
" - those literally do the same thing. (smae idea with all the other hotkey vs command palette versions of an action). They both dispatch the exact same kind of closeTab
action.
Maybe there's something weird with the teardown order of the ConPTY that's nondeterministic here? No idea. We'd probably have to find out where in git bash they're raising different kinds of signals, and seeing which of those is connected to which console teardown paths. I've honestly got no idea, since we're not really the one's sending the SIGUSR1
or the SIGHUP
ourselves.
~Hmm. Maybe I'm seeing this during #14843. Idly I wonder if closing the last tab goes down some different path that ends up not releasing the last tab or the TerminalPage in general for some reason.~
I'm entirely wrong. The lack of a TerminalPage
dtor that I'm seeing in #14843 doesn't repro on main
, so it's gotta be something else
I was crazy off base. The leak I was seeing was entirely my fault, and unrelated to this.
Hey does this still repro on 1.18/? There've been a lot of changes in how process lifetimes are tracked in the last... 3 years...
Windows Terminal Preview version: 1.18.1462.0
For each scenario with Windows Terminal, I am opening a Bash (git for windows) shell, then executing ssh user@server
and running my app.
Single tab open:
SIGUSR1
SIGUSR1
Close Tab
: SIGHUP
Close Pane
: SIGHUP
Close Window
: SIGHUP
Close Tab
: SIGHUP
Close Pane
: SIGUSR1
Close Window
: SIGHUP
SIGHUP
SIGHUP
Two tabs open, tab focused is my app:
SIGHUP
.SIGHUP
Close Tab
: SIGHUP
Close Pane
: SIGHUP
Close Window
: SIGHUP
Close Tab
: SIGUSR1
Close Pane
: SIGHUP
Close Window
: SIGHUP
SIGUSR1
SIGHUP
Two tabs open, tab focused is my NOT app:
SIGHUP
.SIGHUP
Close Other Tabs
: SIGUSR1
SIGHUP
SIGHUP
The results are weirdly inconsistent with what I documented previously. Is it possible that WT is sending BOTH SIGHUP
and SIGUSR1
at the same time?
Wow, this is comprehensive!
Terminal mostly speaks the language of the console, so it's emitting a CTRL_CLOSE_EVENT
or a CTRL_BREAK_EVENT
or something that WSL is picking up. I don't know how they do signal mapping, but I do suspect that there is some difference based on when and how the console session terminates underneath them.
This is using Git for Windows bash / msys bash - not WSL.
WHOOPS, That's what I get for doing a drive-by. Thanks! Most of the thought still stands -- we're sending some upstream signal of those or tearing down the console host before it's ready. I'll have to think about what tracing we'll need to figure this out :)
We've got a theory that this is some sort of weird race condition, somehow. Like, maybe if you ran 1000 of each of those tests[^1], it might come out inconsistently across each of them.
I have no idea how we'd begin to track down what part of the system this is coming from... 🤷
[^1]: we are not actually asking you to run those tests 1000 times 😅
Not sure if this is a related issue or a separate one:
closePane
command
restoreLastClosed
command
closePane
command closed the entire Tab 2, it should restore it as a tab rather than a paneA side issue is that as far as I can tell the restoreLastClosed
command is not documented on this page https://learn.microsoft.com/en-us/windows/terminal/customize-settings/actions
Environment
Not entirely sure where this lies, but starting here since I can't recreate it elsewhere (putty, cmd.exe)
When closing a WSL session by either middle mouse clicking the tab (NOT the X) or by running the "closeTab" command via a hotkey, my ssh session will terminate and the application that's running receives a SIGHUP.
When closing a WSL session by clicking the X on a tab or by running the "closePane" command via a hotkey, my ssh session will terminate and the application that's running receives both SIGUSR1 (first) and SIGHUP.
This isn't an issue per se, but I'm trying to track down a bug in our own application and part of it seems to be related to how the application was terminated. Our end users don't use Windows Terminal, but in trying to understand how to create this scenario I've been working through different SSH clients.
What does Windows Terminal do differently when closing a tab using "closePane" versus "closeTab"?