After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 759196 - SIGUNUSED is not available in POSIX standard
SIGUNUSED is not available in POSIX standard
Status: RESOLVED FIXED
Product: vte
Classification: Core
Component: general
git master
Other FreeBSD
: Normal normal
: ---
Assigned To: VTE Maintainers
VTE Maintainers
Depends on:
Blocks:
 
 
Reported: 2015-12-08 17:31 UTC by Ting-Wei Lan
Modified: 2015-12-11 12:31 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Ting-Wei Lan 2015-12-08 17:31:57 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.
Comment 1 Christian Persch 2015-12-08 17:53:12 UTC
Got a suggestion for a replacement?

#ifndef SIGUNUSED
#define SIGUNUSED 31
#endif

maybe? Or _NSIG ? Or ... ?
Comment 2 Ting-Wei Lan 2015-12-08 18:07:12 UTC
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
Comment 3 Ting-Wei Lan 2015-12-08 18:10:11 UTC
NSIG is not available in POSIX standard, and bash uses 64 when NSIG is not defined.
Comment 4 Christian Persch 2015-12-08 18:31:07 UTC
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.
Comment 5 Ting-Wei Lan 2015-12-08 18:33:25 UTC
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.
Comment 6 Christian Persch 2015-12-08 18:41:03 UTC
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?
Comment 7 Ting-Wei Lan 2015-12-08 19:01:42 UTC
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
Comment 8 Christian Persch 2015-12-10 17:43:21 UTC
Should be fixed on master; please check.
Comment 9 Ting-Wei Lan 2015-12-10 19:31:43 UTC
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.
Comment 10 Christian Persch 2015-12-10 19:47:16 UTC
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?).
Comment 11 Ting-Wei Lan 2015-12-11 12:31:25 UTC
I filed a bug for posix_openpt issue: https://bugzilla.gnome.org/show_bug.cgi?id=759346