简体   繁体   English

我可以捕获除Ctrl-C之外的键盘信号?

[英]What keyboard signal apart from Ctrl-C can I catch?

I have a (C, Linux) application which handles Ctrl-C SIGINT by shutting down. 我有一个(C,Linux)应用程序通过关闭来处理Ctrl-C SIGINT。 I'd like to add another signal handler so that I can use another keystroke combo for "reload configuration while running". 我想添加另一个信号处理程序,以便我可以使用另一个击键组合“运行时重新加载配置”。

So I'm looking from a signal I can send to the foreground process by keystroke, which doesn't force the process to quit or suspend. 所以我从一个信号看起来我可以通过击键发送到前台进程,这不会强制进程退出或挂起。 Are there any others? 还有其他人吗?

You can use ctrl+Z , 你可以使用ctrl+Z

SIGTSTP 

Value = 20 值= 20

For more details refer this link . 有关详细信息,请参阅此链接

你可以尝试Ctrl - \\这是SIGQUIT如果你绝对需要它是一个击键(你可以抓住它)。

Your program can use SIGUSR1 and SIGUSR2 to do whatever it wants, but there's no single-stroke way of sending them like how a Ctrl+C sends a SIGINT signal. 你的程序可以使用SIGUSR1SIGUSR2来做任何你想做的事情,但是没有一个单行程方式发送它们就像Ctrl + C发送SIGINT信号一样。 You have to use something like kill(1) to send the signal, eg kill -USR1 <mypid> . 你必须使用kill(1)类的东西来发送信号,例如kill -USR1 <mypid>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM