什么才是1号在SIG_IGN宏定义的含义是什么? [英] What 's the meaning of the number 1 in SIG_IGN macro definition?
问题描述
#define SIG_IGN (void (*)(int))1
#define SIG_HOLD (void (*)(int))5
#define SIG_ERR ((void (*)(int))-1)
我知道什么是(无效(*)(INT))
表示:投unknown_name到函数指针(INT)返回void
I know what (void (*)(int))
means: cast unknown_name into pointer to function (int) returning void.
但是,什么是意义以下 1
?
But what's the meaning of the following 1
?
的常数被使用,以便它可以从一个有效的函数指针来区分
推荐答案
例如:
#define SIG_DFL ((__sighandler_t)0) /* default signal handling */
#define SIG_IGN ((__sighandler_t)1) /* ignore signal */
#define SIG_ERR ((__sighandler_t)-1) /* error return from signal */
这些常数值都不是东西,你可以调用一个有效的函数地址。因此,他们是因为这可以用来表示如何处理信号的特殊值是有用的。
None of those constant values is something that you could call as a valid function address. So they are useful as special values that can be used to say how to handle signals.
POSIX的方式并没有提到这些常量 1
, 0
或 1
,preferring才说出的符号常量的(在预期的地方,反正)的 < signal.h中方式>
POSIX by the way does not mention these constants -1
, 0
or 1
, preferring to say only symbolic constants (in the expected place, anyway): <signal.h>
.
延伸阅读:
- 执行默认的信号处理
- 24.3.1基本的信号处理 (GNU C库)
- executing default signal handler
- 24.3.1 Basic Signal Handling (The GNU C library)
这篇关于什么才是1号在SIG_IGN宏定义的含义是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!