用于 Windows cmd 行的类似 Linux 的 Ctrl-C(键盘中断)?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/800521/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 06:18:07  来源:igfitidea点击:

Linuxlike Ctrl-C (KeyboardInterrupt) for the Windows cmd line?

windowsterminal

提问by Mark

I've been forced into using a command line in windows and wondered if there were Linux-like keyboard shortcuts? I googled and didn't find what I was looking for.

我被迫在 Windows 中使用命令行,想知道是否有类似 Linux 的键盘快捷键?我用谷歌搜索并没有找到我要找的东西。

Things like ^C, ^Z and such? Thanks all!

诸如 ^C、^Z 之类的东西?谢谢大家!

采纳答案by Logan Capaldo

You can trap ^C on Windows with SIGINT, just like Linux. The Windows shell, such as it is, doesn't support Unix style job control (at least not in a way analogous to Unix shells), and ^Z is actually the ^D analog for Windows.

您可以使用 SIGINT 在 Windows 上捕获 ^C,就像 Linux 一样。Windows shell 不支持 Unix 风格的作业控制(至少不是以类似于 Unix shell 的方式),而 ^Z 实际上是 Windows 的 ^D 模拟。

回答by Mark

Try Ctrl+Break: some programs respond to it instead of Ctrl+C. On some keyboards Ctrl+Breaktranslates to Ctrl+Fn+Pause.

尝试Ctrl+ Break:一些程序响应它而不是Ctrl+ C。在某些键盘上Ctrl+Break转换为Ctrl+ Fn+ Pause

Note also that nothing can cancel synchronous network I/O (such as net view \\invalid) on Windows before Vista.

另请注意,net view \\invalid在 Vista 之前的 Windows 上,没有任何东西可以取消同步网络 I/O(例如)。

回答by Kamil

There are two keyboard combinations that can be used to stop process in Windows command line.

有两种键盘组合可用于在 Windows 命令行中停止进程。

  • Ctrl+Cis the "nicer" method. Programmers can handle this in software. It's possible to write programs that ignore Ctrl+Cas SIGINTsignal completely, or handle Ctrl+Clike a regular keyboard combination.

  • Ctrl+breakis the "harder" method, always sends SIGBREAKsignal and cannot be overridden in software.

  • Ctrl+C是“更好”的方法。程序员可以在软件中处理这个问题。可以编写完全忽略Ctrl+C作为SIGINT信号的程序,或者像常规键盘组合一样处理Ctrl+ C

  • Ctrl+break是“更难”的方法,总是发送SIGBREAK信号并且不能在软件中被覆盖。

回答by 1800 INFORMATION

Ctrl-C does a similar thing in windows as it does in linux.

Ctrl-C 在 windows 中的作用与在 linux 中的作用相似。