2

How do you kill a running terminal in VS Code? Half the time Ctrl+C does nothing and I have to close the application. Is this a bug or a feature?

Kirk Ross
  • 6,413
  • 13
  • 61
  • 104
  • This is operating system specific. On Linux, consider running your program on the command line (e.g. using your shell `/bin/bash` or `/bin/zsh` running in some terminnal emulator) – Basile Starynkevitch Feb 29 '20 at 05:30
  • 2
    Click the trash can to kill the process running in the terminal OR press Ctrl + Z to get your command prompt back, but process will need to be killed in the system monitor on your computer. I'm not sure how to do *exactly* what you want, though. – Sydney Y Feb 29 '20 at 05:31
  • Can you add some details, please? Like, a [example] and the exact steps you take, what you expect, and what you get. -- It might have to do where the focus is. As well it can be your program. – the busybee Feb 29 '20 at 07:17
  • press it twice -- always works for me – ultraGentle Feb 29 '20 at 11:54
  • Just wondering if the solutions at https://stackoverflow.com/questions/46899480/vscode-terminal-terminate-process-without-prompt/52735332#52735332 help? – Mark Mar 03 '20 at 04:22

3 Answers3

5

Click the trash can to kill the process running in the terminal by closing the terminal window

OR

Press Ctrl + Z to get your command prompt back, but the process will need to be killed in the system monitor on your computer.

This is neither a bug nor a feature of VS Code; VS Code is merely providing an interface for the computer's command line controls. The reason Ctrl + C doesn't always work has to do with the process on your computer not hearing your command, which is the process's fault, not the command line interface's.

Sydney Y
  • 2,912
  • 3
  • 9
  • 15
2

What I needed to do, to get this working for me is adding the following key binding in keybindings.json file:

{
    "key": "cmd+c",
    "command": "workbench.action.terminal.sendSequence",
    "args": {
        "text": "\u0003"
    },
    "when": "terminalFocus"
}

Got the info here.

informatik01
  • 16,038
  • 10
  • 74
  • 104
Rutger
  • 966
  • 8
  • 6
-3

As of VSCode 1.42, pressing ctrl+c twice in a row consistently exits the running process in the terminal.

For reference, my system is Mac OS running Catalina. This seems to be specific to the VS code terminal, as running the same process in the system terminal only requires one press.

ultraGentle
  • 5,084
  • 1
  • 19
  • 45