Ubuntu – Why doesn’t Ctrl-C kill the Terminal itself

command line

The terminal is running when we open it.

luvpreet@DHARI-Inspiron-3542:/$

I have just opened it. So, when I press Ctrl+C, why doesn't it kill itself and close the terminal??

Best Answer

Ctrl+C is the interrupt signal. When you type this in a terminal, bash sends SIGINT to the job in the foreground. If there is no job (which is the case when you've just opened a terminal), nothing happens. The terminal emulator program is not a job running in the shell, so, it doesn't get the signal and doesn't close.

If you want to close the terminal with a control key, use Ctrl+D (EOF) which causes bash to exit (and closes the terminal too).

See also: Bash Beginner's Guide on signals and in more depth How signal handling works
note: this answer has been edited since comments were posted