Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where is SIGUNUSED exactly defined in header files?

Tags:

c

linux

signals

I have some code that has to compile for multiple platforms. The following will make the code compile but I want to know where the SIGUNUSED symbol is actually defined:

Working Code

#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;
}

...

I have looked for SIGUNUSED in /usr/include with no hits. It is not in signal.h. Where is it coming from?

Update:

I did not think the signal definition would be outside of signal.h as the response indicated a recursive search did find the definition:

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

Thanks!

like image 371
ojblass Avatar asked Oct 21 '25 00:10

ojblass


1 Answers

(I'm answering since this question ranks high on google results regarding SIGUNUSED)

Since glibc 2.26 SIGUNUSED has been removed and we're advised to use SIGSYS instead (which has the same value).

For legacy compatibility, use

#define SIGUNUSED SIGSYS

or just

#define SIGUNUSED 31
like image 57
kralyk Avatar answered Oct 23 '25 13:10

kralyk