Fig. 1 Pressing two times CTRL+C in Terminal does not act but puts two line breaks in Matlab's command line

enter image description here

I think there is something wrong with the keybindings. I have tried both Windows and Emacs unsuccessfully. The keybinding works in Mathematica. Debian 8.x is supported by MathWorks for Matlab so it should be supported.

Related conditions

  1. Typing CTRL+C in Matlab's prompt does not enter kill but a line break
  2. ...

Differential solutions

  1. Open Matlab's prompt and enter exit.
  2. Open System Monitor and give kill and/or force kill signal to Matlab

Matlab: 2016a, 2016b prerelease
Hardware: Asus Zenbook UX303UA
OS: Debian 8.5
Linux kernel: 4.6 (backports)
Related: [could not find finally anything; most conditions are related to the condition where you type the thing directly in Matlab's prompt]
Service ticket of MathWorks: 02154064

  • Try ctrl-D, works for some apps. Also not all apps have a keybinding that close them. – cutrightjm Sep 6 '16 at 15:05
  • Note that Bash doesn't die when you type Ctrl-C, and you are not logged out. Same thing! Bash is just software; whatever Bash can do, another programming language shell can be programmed to do. – Kaz Sep 7 '16 at 2:47

The default meaning of Ctrl+C is to send the signal SIGINT. The conventional meaning of SIGINT is to halt the task that's currently running in the foreground and let the user provide new input. I'm using task in the informal meaning of whatever the computer is doing. This is not necessarily a separate process. In a program like Matlab that reads successive commands and processes them — a REPL — SIGINT is supposed to bring the user back to that program's prompt, not to kill the program. When the foreground task is a program that does one job and then exits, SIGINT is supposed to kill the program since that's the way to bring the user back to the shell prompt.

Try Ctrl+\. This sends the signal SIGQUIT, and the conventional meaning of SIGQUIT is to exit immediately and (if the system is configured for it) leave a core dump. Not all programs keep that meaning, I don't know if Matlab does.

If the kill signal keys aren't working, try Ctrl+Z to send SIGSTOP which suspends the program and brings you back to a shell prompt where you can send some other signal. When you suspend a job, the shell shows a message like

[1]+  Stopped       matlab

The number in brackets is the job number. You can use %1 instead of a process ID to send a signal to the process from that shell, e.g. kill %1 here to send SIGTERM (normal kill signal), and if that doesn't work then kill -KILL %1 (SIGKILL, the kill signal that doesn't give the application a chance).

If you can't interrupt the application to reach the shell running on that terminal, kill it from another shell running in another terminal.


MATLAB is not mathematica; it appears the programmers of MATLAB decided to either block SIGINT (the ^Cs during the startup) or installed a custom handler that emits a newline (when in command prompt mode). This is typical behavior for a shell environment.


Your shell also does not die when you type Ctrl-C. The current command line is canceled, and you get a new prompt, instead of the shell terminating and logging you out, or returning to the previous program.

A system command shell like Bash is just software; whatever it can do, any other programming language shell can be programmed to do, using the same techniques.

While a typical programming language shell is in interactive editing mode, the TTY is in raw mode and Ctrl-C is just an ordinary character. The action of canceling the current command line can be implemented as if it were a special type of editing command, bound to the Ctrl-C key.

In addition, some programming language shells also allow the evaluation of code to be interrupted. That is usually achieved by, while code is running, restoring the TTY mode to the usual settings which map Ctrl-C to the generation of a SIGINT signal, which is handled. Somehow the handling is translated to a cancelation of the running code. An interpreter written in C might perform a longjmp to a location set up using setjmp by the interactive prompt. The SIGINT signal handler itself might just set a global variable which says "interrupt raised". The interpreter might check this variable from time to time and turn it into an exception. That avoids the added complexity of jumping out of a signal handler.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.