ima*_*ake 43 linux bash signals ctrl signal-handling
在Linux/Unix上有信号.在CtrlC一个(SIGINT
)是显而易见的我.现在,在其他一些应用程序中有信号通过CtrlX?!这甚至是信号还是产生逃逸序列?还有什么我可以用作类似CtrlC(CtrlV,CtrlX...)的东西吗?
如果有人有线索,我不熟悉C而不是bash,但是对这两种语言的答案表示赞赏!
Dam*_*mon 51
可能存在误解.CtrlC不会产生信号.完全可以按CtrlC任何地方,不会发生任何不好的事情(例如在每个文本编辑器或文字处理器中,这是"复制"的事实标准).
但是,当您在shell中运行程序时,您的按键实际上会进入shell,而不是进入您的程序.shell将(几乎)所有内容转发到程序的stdin,并将来自stdout的任何内容转发到终端或其他进程或文件(如果使用管道或重定向).
如果shell看到你按CtrlC,那么shell发送中断信号.但这真的只是shell所做的事情,而不是因为关键组合而神奇地发生的事情.
关于CtrlX,你可能意味着CtrlZ.这会停止一个进程,shell会输出一个数字,您可以使用该数字fg
使其再次运行.
nin*_*alj 16
终端为某些键序列赋予特殊含义.这包括删除一个字符,删除到行的开头(CtrlU),...
特别是,当ISIG
启用终端本地模式时:
VINTR
(通常CtrlC)生成SIGINT
(由用户中断).VQUIT
(通常Ctrl\)生成一个SIGQUIT
(如SIGINT,但也转储核心).VSUSP
(通常CtrlZ)生成SIGTSTP
(通过终端I/O停止).VDSUSP
(在某些系统上,而不是在Linux上)SIGTSTP
在程序尝试读取它时生成.以上是可配置的.这在termios(3)联机帮助页上有记录.
Nob*_*lis 13
来自维基百科
Ctrlx Ctrle :编辑$ EDITOR程序中的当前行,如果未定义则编辑vi.
Ctrlx Ctrlr :读入inputrc文件的内容,并合并在那里找到的任何绑定或变量赋值.
Ctrlx Ctrlu :增量撤消,分别记住每一行.
Ctrlx Ctrlv :显示有关当前bash实例的版本信息.
Ctrlx Ctrlx:将光标替换为旧位置.(Cx,因为x具有交叉形状).
另一个用法Ctrlx是*
在shell中键入命令时展开.
说你有:
$ ls *
Run Code Online (Sandbox Code Playgroud)
按Ctrlx,然后*将展开*
到当前目录中的所有项目,如下所示:
$ ls dir1 dir2 file1 file2 file3`
Run Code Online (Sandbox Code Playgroud)
您也可以参考SuperUser上的这个主题,了解我上面描述的用法.
在Linux/Unix上有信号.在Ctrl+ C一个(
SIGINT
)的明显,我...
如果您需要系统上可用的信号列表,那么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 ())
Run Code Online (Sandbox Code Playgroud)