GNOME Bugzilla – Bug 759196
SIGUNUSED is not available in POSIX standard
Last modified: 2015-12-11 12:31:25 UTC
This problem was found when compiling vte on FreeBSD: pty.cc:137:29: error: use of undeclared identifier 'SIGUNUSED' for (int n = 1; n < SIGUNUSED; n++) ^ SIGUNUSED is not specified in POSIX standard, so I think we should not use it unconditionally.
Got a suggestion for a replacement? #ifndef SIGUNUSED #define SIGUNUSED 31 #endif maybe? Or _NSIG ? Or ... ?
It seems that bash uses NSIG (from siglist.c), but its meaning varies on different operating systems. On Linux: /* bits/signum.h */ #define SIGSYS 31 /* Bad system call. */ #define SIGUNUSED 31 #define _NSIG 65 /* Biggest signal number + 1 (including real-time signals). */ /* signal.h */ #ifdef __USE_MISC # define NSIG _NSIG #endif On FreeBSD: /* sys/signal.h */ #define SIGUSR2 31 /* user defined signal 2 */ #if __BSD_VISIBLE #define SIGTHR 32 /* reserved by thread library.*/ #define SIGLWP SIGTHR #define SIGLIBRT 33 /* reserved by real-time library. */ #endif #define SIGRTMIN 65 #define SIGRTMAX 126 #if __BSD_VISIBLE #define NSIG 32 /* number of old signals (counting 0) */ #endif On NetBSD: /* sys/signal.h */ #define _NSIG 64 #if defined(_NETBSD_SOURCE) #define NSIG _NSIG #endif /* _NETBSD_SOURCE */ #define SIGUSR2 31 /* user defined signal 2 */ #define SIGPWR 32 /* power fail/restart (not reset when caught) */ #ifdef _KERNEL #define SIGRTMIN 33 /* Kernel only; not exposed to userland yet */ #define SIGRTMAX 63 /* Kernel only; not exposed to userland yet */ #endif On OpenBSD: /* sys/signal.h */ #define _NSIG 33 /* counting 0 (mask is 1-32) */ #if __BSD_VISIBLE #define NSIG _NSIG #endif #define SIGUSR2 31 /* user defined signal 2 */ #if __BSD_VISIBLE #define SIGTHR 32 /* thread library AST */ #endif
NSIG is not available in POSIX standard, and bash uses 64 when NSIG is not defined.
So NSIG is available on linux, *BSD, and I just checked it's available on illumos, too. And we don't do strict POSIX, so that's not a problem.
NSIG is real-time signals + 1 on Linux and NetBSD, but it doesn't include real-time signals and signals that are reserved for libraries on FreeBSD.
Hmm... the old code didn't reset the RT signals, nor does the new one going only up to SIGUNUSED. Should we reset all those other signals too? If NSIG varies too much, maybe 8*sizeof(sigset_t) is a good replacement?
8 * sizeof(sigset_t) should include all signals we have to reset although it can be large. I think we can use it and I hope it is safe. Linux sizeof(sigset_t) = 128 FreeBSD sizeof(sigset_t) = 16 NetBSD sizeof(sigset_t) = 16 OpenBSD sizeof(sigset_t) = 4
Should be fixed on master; please check.
SIGUNUSED issue is fixed now, but vte doesn't builds without --enable-debug. vte doesn't work because using O_NONBLOCK in posix_openpt is not allowed on FreeBSD.
The debug problem is bug 759314 which I'll fix soon. Let's take the pty problem to a new bug. I think we just need to fix configure checks so that we'll use openpty() for all BSDs (actually I thought openpty support had been added specificially because BSDs lack posix_openpt?).
I filed a bug for posix_openpt issue: https://bugzilla.gnome.org/show_bug.cgi?id=759346