terminal: Terminal hangs on exit with 'process exited with code 127' message
Hi! I’ve noticed that on newer releases(starting from 0.8.x) when you try to close the terminal(with exit command or ctrl+d) after executing a command that returned an error status code, the tab hangs with the message: [process exited with code This happens on wsl and cmd.
Environment
Microsoft Windows [Version 10.0.18363.657]
Windows Terminal version: 0.9.433.0
Steps to reproduce
Execute from cmd a command that produce an error then try to close with exit command: e.g:
C:\Users\cristi>asd
'asd' is not recognized as an internal or external command,
operable program or batch file.
C:\Users\cristi>exit
[process exited with code 9009]
Same behavior in WSL when exit or ctrl+d:
/mnt/c/Users/cristi$ false
/mnt/c/Users/cristi$ exit
[process exited with code 1]
Expected behavior
Windows Terminal tab should be closed.
Actual behavior
Windows Terminal tab freeze.
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 35
- Comments: 20 (7 by maintainers)
Commits related to this issue
- Graceful zsh logout Ref: https://github.com/microsoft/terminal/issues/4573#issuecomment-601895295 — committed to cympfh/dots by cympfh 3 years ago
@carragom Oh, that explains it -
closeOnExit
is a Profile setting. See this doc: https://github.com/microsoft/terminal/blob/master/doc/cascadia/SettingsSchema.md#profilesIf you want it for all your profiles, you could try the following:
Hey so for the record, we already have a key bound to “close pane” by default, and have for some time now 😃 <kbd>Ctrl+Shift+W</kbd>, which is the default keybinding for
closePane
will try to close the active pane, and if there’s only one pane in the tab, it’ll just close the tab. So if you’ve been using that to close tabs, it’ll just work for closing panes as well./cc @DHowett-MSFT, because
"closeOnExit":"always"
should work the way you want.Hi, I agree that not closing the tab/pane on error is correct. But one question remains, how do I close a split pane after it got to that dead state? See screenshot.
When a terminal only support tabs, as it was before splits landed, this is not too problematic because I can open a new tab and close the dead one (not ideal but acceptable). But now that splits are supported, closing a tab might mean loosing work since a tab might contain more than one terminal. There seem to be an action to close a pane here but this should have better default behavior.
My proposal for this would be
[process exited with code 1]
with something like[process exited with code 1, press <key> to exit]
. Wherekey
could be enter, space or another sensible key. And of course implement the functionality of closing the pane/tab when the key is pressed.closeOnExit
option but I have it onalways
and the pane/tab does not close.On other related comments like this one the default behavior of never closing is suppose to exist to prevent a terminal from closing on startup because of a miss configuration on the shell. This behavior should never be lost even if proposal number 2 gets implemented.
I know I could place something like this inside my
~/.bash_logout
to achieve what I want but that is just bad UX and specific to bash. This should be handled in the terminal and work with any shell.If there already exist a way to achieve any of my proposals please point me on the right direction. Thanks.
Thanks a lot, when placing the
closeOnExit
on the specific profile it behaves as expected.I added an alias called “exit” on my .bash_profile: alias exit=“exit 0”. It solved the problem for me.
I’ll add that this is happening under powershell when it’s not expected, for example running a python script and hitting “Ctrl+C” to kill the script. When this happens it requires me to open a new terminal tab and re-navigate to my working directory.
Thanks for the quick response, Ctrl+Shift+W does close the dead pane/tab but I still think
press <key> to exit
would be a better feature.As for
"closeOnExit": "always"
I’m not sure why it does not work for me, I do have it in the global section and not on any specific profile.Hey there! This is, unfortunately, by design; it’s highly conserved across different types of shells (bash, zsh, powershell and CMD all do the same thing) and the behavior of not closing the tab is in line with Ubuntu’s terminal: https://github.com/microsoft/terminal/issues/4223#issuecomment-574834181