在终端中使用 ctrl-x 时会发送哪个信号?

发布于 2024-11-25 01:04:47 字数 333 浏览 6 评论 0原文

在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

与他有关 2024-12-02 01:04:47

要获取所有终端控制字符分配:

stty -a

To get all the terminal control character assignments:

stty -a
澜川若宁 2024-12-02 01:04:47

可能存在误会。 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.

无声情话 2024-12-02 01:04:47

来自 维基百科

Ctrlx Ctrle :编辑 $EDITOR 程序中的当前行,或 vi
如果未定义。

Ctrlx Ctrlr :读入 inputrc 文件的内容,并
合并在那里找到的任何绑定或变量分配。

Ctrlx Ctrlu :增量撤消,每行单独记住。

Ctrlx Ctrlv :显示当前实例的版本信息
bash。

Ctrlx Ctrlx :将光标替换为其旧位置。 (CX,
因为 x 具有交叉形状)。

Ctrlx 的另一种用法是在 shell 中键入命令时展开 *

假设您有:

$ ls *

Ctrlx 然后按 * 会将 * 扩展到当前目录中的所有项目像这样:

$ ls dir1 dir2 file1 file2 file3`

您还可以参考此主题SuperUser 用于我上面描述的用法。

From Wikipedia

Ctrlx Ctrle : Edits the current line in the $EDITOR program, or vi
if undefined.

Ctrlx Ctrlr : Read in the contents of the inputrc file, and
incorporate any bindings or variable assignments found there.

Ctrlx Ctrlu : Incremental undo, separately remembered for each line.

Ctrlx Ctrlv : Display version information about the current instance
of bash.

Ctrlx Ctrlx : Alternates the cursor with its old position. (C-x,
because x has a crossing shape).

One additional usage of Ctrlx is to expand the * when typing a command in the shell.

Say you have:

$ ls *

Pressing Ctrlx and then * will expand * to all items in the current directory to something like this:

$ ls dir1 dir2 file1 file2 file3`

You can also refer to this topic on SuperUser for the usage I described above.

心的位置 2024-12-02 01:04:47

终端为某些按键序列赋予特殊含义。这包括删除一个字符,删除到行首( 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 a SIGINT (interrupted by user).
  • VQUIT (usually Ctrl\) generates a SIGQUIT (like SIGINT, but also dump core).
  • VSUSP (usually CtrlZ) generates a SIGTSTP (stop by terminal I/O).
  • VDSUSP (on some systems, not on Linux) generates a SIGTSTP when the program tries to read it.

The above are configurable. This is documented on the termios(3) manpage.

葬﹪忆之殇 2024-12-02 01:04:47

在 Linux/Unix 上有信号。 Ctrl+C 一个 (SIGINT) 对我来说是显而易见的......

如果您需要系统上可用的信号列表,那么 < code>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 ())

On Linux/Unix there are signals. The Ctrl+C one (SIGINT) is obvious to me...

If you need a list of signals available on your system, then signum.h can be helpful. Below is from 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 ())
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文