在terminal中使用ctrl-x时发送哪个信号?

在Linux / Unix上有信号。 Ctrl C 1( SIGINT )对我来说是显而易见的。 现在,在其他一些应用程序中有通过Ctrl X的信号! 这是甚至是一个信号,或者它产生一个逃生序列? 还有什么我可以使用类似于Ctrl CCtrl VCtrl X …)?

如果有人有线索,我不仅比bash更熟悉C,而且赞赏这两种语言的答案!

要获得所有的terminal控制字符分配:

 stty -a 

有可能是一个误解。 Ctrl C不会生成信号。 完全可以在任何地方按下Ctrl C ,并且不会发生任何坏事(例如在每个文本编辑器或文字处理器中,这是“复制”的事实上的标准)。

但是,当你在shell中运行一个程序 ,你的按键真的会进入shell,而不是进入你的程序。 shell将几乎所有的东西都转发到你的程序的stdin,并把任何来自stdout的东西转发到terminal或其他进程或文件(如果你使用pipe道或redirect的话)。

如果shell看到你按下Ctrl C ,那么shell会发送中断信号 。 但是这实际上只是壳的作用,而不是由于关键组合而奇迹般地发生的事情。

关于Ctrl X ,你可能是指Ctrl Z。 这会停止一个进程,并且shell会输出一个可以和fg一起使用的数字,以使其再次运行。

terminal为特定的按键序列赋予特殊的含义。 这包括删除一个字符,删除到行首( Ctrl U ),…

具体来说,当terminalISIG本地模式启用时:

  • VINTR (通常是Ctrl C )生成一个SIGINT (由用户中断)。
  • VQUIT (通常是Ctrl \ )生成一个SIGQUIT (如SIGINT,但也是转储核心)。
  • VSUSP (通常是Ctrl Z )产生一个SIGTSTP (由terminalI / O停止)。
  • VDSUSP (在某些系统上,而不是在Linux上)在程序尝试读取时生成一个SIGTSTP

以上是可configuration的。 这是在termios(3)手册页上logging的。

从维基百科

Ctrl + Ctrl e :编辑$ EDITOR程序中的当前行,或者vi(如果未定义)。

Ctrl x Ctrl r :读入inputrc文件的内容,并且包含在那里find的任何绑定或variables赋值。

Ctrl x Ctrl u :增量撤销,分别记住每行。

Ctrl + Ctrl v :显示当前bash实例的版本信息。

Ctrl x Ctrl x :用其旧位置交替光标。 (Cx,因为x具有交叉形状)。

Ctrl x的另一个用法是在shell中input命令时展开*

假设你有:

 $ ls * 

Ctrl + ,然后**展开到当前目录中的所有项目,如下所示:

 $ ls dir1 dir2 file1 file2 file3` 

您也可以在SuperUser上参考上述用法。

在Linux / Unix上有信号。 Ctrl + CSIGINT )对我来说是显而易见的…

如果您需要系统中可用的信号列表,那么signum.h会很有帮助。 以下是Debian 7.3:

 /* Signals. */ #define SIGHUP 1 /* Hangup (POSIX). */ #define SIGINT 2 /* Interrupt (ANSI). */ #define SIGQUIT 3 /* Quit (POSIX). */ #define SIGILL 4 /* Illegal instruction (ANSI). */ #define SIGTRAP 5 /* Trace trap (POSIX). */ #define SIGABRT 6 /* Abort (ANSI). */ #define SIGIOT 6 /* IOT trap (4.2 BSD). */ #define SIGBUS 7 /* BUS error (4.2 BSD). */ #define SIGFPE 8 /* Floating-point exception (ANSI). */ #define SIGKILL 9 /* Kill, unblockable (POSIX). */ #define SIGUSR1 10 /* User-defined signal 1 (POSIX). */ #define SIGSEGV 11 /* Segmentation violation (ANSI). */ #define SIGUSR2 12 /* User-defined signal 2 (POSIX). */ #define SIGPIPE 13 /* Broken pipe (POSIX). */ #define SIGALRM 14 /* Alarm clock (POSIX). */ #define SIGTERM 15 /* Termination (ANSI). */ #define SIGSTKFLT 16 /* Stack fault. */ #define SIGCLD SIGCHLD /* Same as SIGCHLD (System V). */ #define SIGCHLD 17 /* Child status has changed (POSIX). */ #define SIGCONT 18 /* Continue (POSIX). */ #define SIGSTOP 19 /* Stop, unblockable (POSIX). */ #define SIGTSTP 20 /* Keyboard stop (POSIX). */ #define SIGTTIN 21 /* Background read from tty (POSIX). */ #define SIGTTOU 22 /* Background write to tty (POSIX). */ #define SIGURG 23 /* Urgent condition on socket (4.2 BSD). */ #define SIGXCPU 24 /* CPU limit exceeded (4.2 BSD). */ #define SIGXFSZ 25 /* File size limit exceeded (4.2 BSD). */ #define SIGVTALRM 26 /* Virtual alarm clock (4.2 BSD). */ #define SIGPROF 27 /* Profiling alarm clock (4.2 BSD). */ #define SIGWINCH 28 /* Window size change (4.3 BSD, Sun). */ #define SIGPOLL SIGIO /* Pollable event occurred (System V). */ #define SIGIO 29 /* I/O now possible (4.2 BSD). */ #define SIGPWR 30 /* Power failure restart (System V). */ #define SIGSYS 31 /* Bad system call. */ #define SIGUNUSED 31 #define _NSIG 65 /* Biggest signal number + 1 (including real-time signals). */ #define SIGRTMIN (__libc_current_sigrtmin ()) #define SIGRTMAX (__libc_current_sigrtmax ())