在终端中使用 ctrl-x 时会发送哪个信号?
在 Linux/Unix 上有信号。 CtrlC 一个(SIGINT
)对我来说是显而易见的。 现在,在其他一些应用程序中,有通过 CtrlX 发出的信号?! 这到底是一个信号还是会生成一个转义序列? 还有什么我可以用作类似于 CtrlC ( CtrlV, Ctrl< /kbd>X ...)?
如果有人有线索,我对 C 的熟悉程度超过 bash,但是两种语言的答案都值得赞赏!
On Linux/Unix there are signals. The CtrlC one (SIGINT
) is obvious to me.
Now, in some other applications there are signals via CtrlX?!
Is that even a signal or does it generate an escape sequence?
Is there anything else I can use as something similar to CtrlC ( CtrlV, CtrlX ...)?
If anyone has a clue, im familiar with C more than bash, but answers in both languages are appreciated!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
要获取所有终端控制字符分配:
To get all the terminal control character assignments:
可能存在误会。 CtrlC 不生成信号。完全有可能在任何地方按 CtrlC ,并且不会发生不好的事情(例如在每个文本编辑器或文字处理器中,这是“的事实标准”复制”)。
但是,当您在 shell 中运行程序时,您的按键实际上会进入 shell,而不是进入您的程序。 shell 会将(几乎)所有内容转发到程序的标准输入,并将来自标准输出的任何内容转发到终端或另一个进程或文件(如果您使用管道或重定向)。
如果 shell 发现您按了 CtrlC,则 shell 会发送中断信号。但这实际上只是 shell 所做的事情,而不是由于组合键而神奇地发生的事情。
关于 CtrlX,您可能指的是 CtrlZ。这会停止进程,并且 shell 会输出一个数字,您可以将其与
fg
一起使用以使其再次运行。There is possibly a misunderstanding. CtrlC does not generate a signal. It is perfectly possible to press CtrlC anywhere, and no bad things will happen (for example in every text editor or word processor, that's the de-facto-standard for "copy").
However, when you run a program in the shell, then your keypresses really go into the shell, not into your program. The shell will forward (almost) everything to your program's stdin, and forward anything coming from stdout to either the terminal or another process or a file (if you used a pipe or redirection).
If the shell sees you press CtrlC, then the shell sends the interrupt signal. But that's really just something the shell does, not something that magically happens because of the key combination.
About CtrlX, you probably meant CtrlZ. This stops a process, and the shell outputs a number which you can use with
fg
to make it run again.来自 维基百科
Ctrlx 的另一种用法是在 shell 中键入命令时展开
*
。假设您有:
按 Ctrlx 然后按 * 会将
*
扩展到当前目录中的所有项目像这样:您还可以参考此主题SuperUser 用于我上面描述的用法。
From Wikipedia
One additional usage of Ctrlx is to expand the
*
when typing a command in the shell.Say you have:
Pressing Ctrlx and then * will expand
*
to all items in the current directory to something like this:You can also refer to this topic on SuperUser for the usage I described above.
终端为某些按键序列赋予特殊含义。这包括删除一个字符,删除到行首( CtrlU ),...
具体来说,当终端
ISIG
本地模式为启用:VINTR
(通常为CtrlC)生成SIGINT
(由用户中断)。VQUIT
(通常是Ctrl\)生成一个SIGQUIT
(类似于SIGINT,但也转储核心)。VSUSP
(通常为 CtrlZ)生成SIGTSTP
(由终端 I/O 停止)。VDSUSP
(在某些系统上,而不是Linux)时,它会生成SIGTSTP
。以上是可配置的。这记录在 termios(3) 联机帮助页。
The terminal assigns special meaning to certain key sequences. This include deleting a character, deleting to the start of line ( CtrlU ), ...
Specifically, when the terminal
ISIG
local mode is enabled:VINTR
(usually CtrlC) generates aSIGINT
(interrupted by user).VQUIT
(usually Ctrl\) generates aSIGQUIT
(like SIGINT, but also dump core).VSUSP
(usually CtrlZ) generates aSIGTSTP
(stop by terminal I/O).VDSUSP
(on some systems, not on Linux) generates aSIGTSTP
when the program tries to read it.The above are configurable. This is documented on the termios(3) manpage.
如果您需要系统上可用的信号列表,那么 < code>signum.h 可能会有所帮助。以下来自 Debian 7.3:
If you need a list of signals available on your system, then
signum.h
can be helpful. Below is from Debian 7.3: