TheRealTengri
TheRealTengri

Reputation: 1361

Why does ctrl+c have to be the combination to cause an error (e.g. KeyboardInterrupt)?

In almost, if not every, programming language, pressing ctrl+c cancels your code. Why does it specifically have to be ctrl+c? So in other words, what made the developers of programming languages decide that ctrl+c has to be the combination to cancel the code and cause an error?

Upvotes: 3

Views: 151

Answers (3)

gregory
gregory

Reputation: 13023

It doesn't "have to be" anything, it is a convention formed over a long history: Control-C, "C" for cancel, was I think first used in TOPS-10, a Digital Equipment Corporation (DEC) mainframe operating system used in the late 1960s. The control key itself goes back much further, used on telegraphs and teletypewriters to key in non-printing characters. The idea of non-printing characters controlling a machine without sending a message has an even longer history, including procedure signs in Morse code, "NUL" and "DEL" in Baudot code, and other late 19th-century teleprinter standards and their devices.

Upvotes: 3

Mayank Porwal
Mayank Porwal

Reputation: 34086

Ctrl + C is an interrupt sent manually. You can do it programatically using signal.SIGINT:

process = subprocess.Popen(..)
process.send_signal(signal.SIGINT)

Upvotes: 1

MYousefi
MYousefi

Reputation: 1008

Ctrl+C is not a programming language thing. It is an "interrupt" signal sent to the process executing.

Upvotes: 2

Related Questions