[英]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.在几乎(如果不是所有)编程语言中,按 ctrl+c 会取消您的代码。 Why does it specifically have to be ctrl+c?
为什么一定要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?
那么换句话说,是什么让编程语言的开发人员决定 ctrl+c 必须是取消代码并导致错误的组合?
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.它不是“必须是”任何东西,它是由悠久历史形成的约定:Control-C,“C”表示取消,我认为它首先用于 TOPS-10,一个数字设备公司 (DEC) 大型机运行1960 年代后期使用的系统。 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.
非打印字符在不发送消息的情况下控制机器的想法具有更长的历史,包括摩尔斯电码中的程序标志、鲍多码中的“NUL”和“DEL”,以及其他 19 世纪后期的电传打印机标准及其设备。
Ctrl+C is not a programming language thing. Ctrl+C 不是编程语言。 It is an "interrupt" signal sent to the process executing.
它是发送给正在执行的进程的“中断”信号。
Ctrl + C
is an interrupt sent manually. Ctrl + C
是手动发送的中断。 You can do it programatically using signal.SIGINT
:您可以使用
signal.SIGINT
以编程方式执行此操作:
process = subprocess.Popen(..)
process.send_signal(signal.SIGINT)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.