avatar
question about UNIX Signal# Unix - 噫吁兮,危乎高哉
j*e
1
I install a signal handler for a process.
The handler will catch all the signals except 9 and 23, and do nothing but
"print", and so on.
I found out that that: When the process receive the same signal for a second
time, the handler will not function anymore. And default action for that
signal will take effect.
I can't find any book mention such problem.
Is this a bug in my program, or it is the way that signal works?
avatar
m*e
2

This is how signal works on some Unix platform. You need to catch the signal
again in your signal handler.

【在 j*******e 的大作中提到】
: I install a signal handler for a process.
: The handler will catch all the signals except 9 and 23, and do nothing but
: "print", and so on.
: I found out that that: When the process receive the same signal for a second
: time, the handler will not function anymore. And default action for that
: signal will take effect.
: I can't find any book mention such problem.
: Is this a bug in my program, or it is the way that signal works?

avatar
o*z
3
If you set SA_RESETHAND and the signal is caught,
the disposition of the signal is automatically reset to SIG_DFL

【在 j*******e 的大作中提到】
: I install a signal handler for a process.
: The handler will catch all the signals except 9 and 23, and do nothing but
: "print", and so on.
: I found out that that: When the process receive the same signal for a second
: time, the handler will not function anymore. And default action for that
: signal will take effect.
: I can't find any book mention such problem.
: Is this a bug in my program, or it is the way that signal works?

avatar
p*f
4

If you are using signal(2), change to sigaction(2).

【在 j*******e 的大作中提到】
: I install a signal handler for a process.
: The handler will catch all the signals except 9 and 23, and do nothing but
: "print", and so on.
: I found out that that: When the process receive the same signal for a second
: time, the handler will not function anymore. And default action for that
: signal will take effect.
: I can't find any book mention such problem.
: Is this a bug in my program, or it is the way that signal works?

相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。