我有一些必须为多个平台编译的代码。以下将使代码编译,但我想知道SIGUNUSED符号实际定义的位置:
工作代码
#ifdef LINUX
#define SIGEMT SIGUNUSED
#endif
...
void set_sig_trap()
{
signal( SIGHUP, Signal ); /* floating point exception */
signal( SIGINT , Signal ); /* Interrupt */
signal( SIGQUIT, Signal ); /* quit */
signal( SIGILL, Signal ); /* Illegal instruction */
signal( SIGTRAP, Signal ); /* trace trap */
signal( SIGABRT, Signal ); /* Process abort signal */
signal( SIGEMT, Signal ); /* EMT instruction */
signal( SIGFPE, Signal ); /* Floating point exception */
signal( SIGBUS, Signal ); /* bus error */
signal( SIGSEGV, Signal ); /* Segmentation violation */
signal( SIGSYS, Signal ); /* bad argument to system call */
signal( SIGPIPE, Signal ); /* write on a pipe - no one to read it */
signal( SIGTERM, Signal ); /* Software termination sig. from kill */
signal( SIGALRM, Signal ); /* alarm clock */
return;
}
...
我在/ usr / include中搜索过没有命中的SIGUNUSED。它不在signal.h中。它来自哪里?
更新
我认为信号定义不在signal.h之外,因为响应表明递归搜索确实找到了定义:
me@mymachine.:/usr/include $ grep -d recurse SIGUNUSED *
asm/signal.h:#define SIGUNUSED 31
asm-arm/signal.h:#define SIGUNUSED 31
asm-ia64/signal.h:/* signal 31 is no longer "unused", but the SIGUNUSED macro remains for backwards compatibility */
asm-ia64/signal.h:#define SIGUNUSED 31
asm-parisc/signal.h:#define SIGUNUSED 31
asm-parisc/signal.h:#define SIGRESERVE SIGUNUSED
asm-powerpc/signal.h:#define SIGUNUSED 31
asm-s390/signal.h:#define SIGUNUSED 31
asm-x86/signal.h:#define SIGUNUSED 31
bits/signum.h:#define SIGUNUSED 31
谢谢!
答案 0 :(得分:2)
我看到它在bits/signum.h
中定义,其中包含signal.h
:
#define SIGUNUSED 31
也许你忘了递归grep?
答案 1 :(得分:1)
(我正在回答,因为该问题在Google关于SIGUNUSED
的搜索结果中排名很高)
从glibc 2.26 SIGUNUSED
has been removed开始,我们建议改用SIGSYS
(具有相同的值)。
要获得旧版兼容性,请使用
#define SIGUNUSED SIGSYS
或者只是
#define SIGUNUSED 31