Terminal: Ctrl+W doesn't terminate shells properly (so they can't do teardown and cleanup things)

Created on 15 Jul 2019  路  8Comments  路  Source: microsoft/terminal

Environment

Windows build number: Microsoft Windows [Version 10.0.18917.1000]
Windows Terminal version (if applicable): 0.2.1831.0

Steps to reproduce

Exit a mingw bash shell using a keyboard shortcut to close the tab

Expected behavior

exit is sent to the shell, process is terminated, if closing a running process the user is warned

Actual behavior

Terminal is detached and not killed

Area-Interop Help Wanted Issue-Bug Product-Terminal

Most helpful comment

This is absolutely a bug, we shouldn't go and add a new "command to send on exit". That's probably not a winning strategy.

We constrain our shells into job objects, so they _should_ absolutely be getting terminated when the tab is closed.

All 8 comments

Maybe we need to consider having an exitCommand setting? Though, what would happen if you launched a process from bash where exit did _not_ exit the program? For example, vim. How would we determine when to send exit to the commandline application?

Most terminal apps I've used on other platforms will warn when pressing Ctrl+W if anything else is running, on the assumption that the user probably doesn't want to kill the shell after all, and if they really do then probably all bets are off (you could send Ctrl+C then exit but that's a much less predictable use case anyway).

This is absolutely a bug, we shouldn't go and add a new "command to send on exit". That's probably not a winning strategy.

We constrain our shells into job objects, so they _should_ absolutely be getting terminated when the tab is closed.

CTRL + W is also used in a number of curses based apps... need a way to disable it as a kill switch so it can pass through instead

yup, that's why Mac has separation between Ctrl and Cmd, and Linux terminals use Ctrl+Shift for any terminal window shortcuts so that Ctrl shortcuts can be sent directly to the term. Not sure if you want to adopt that convention here too.

Ctrl+Shift+W must be used to close the terminal instead.

Ctrl + W -> Split, Toggle, or something else panes (with alphabetic keys) in Vim, or Cut selected text or Write current file (with Ctrl +X) in Emacs
Ctrl + C -> Quit current application
Ctrl + V -> Start selecting text in Vim or PageDown in Emacs

+1 to exitCommand
I use terminal with docker desktop, running as default ENV for development, every new tab started with command like docker start -ti dev_env zsh, so when I close the tab, I would like to send exit 0 to the zsh process, and then tab will be closed since exit code is 0.

Also update I can autoclose background zsh process with setting TMOUT env for idle timeout as workaround but it's not good because when you leave tabs open it's closes after TMOUT time, since there is no SIGALRM handling.

Was this page helpful?
0 / 5 - 0 ratings