Fix "struct sigaction" structure for rt_sigaction.
authorDanny Milosavljevic <dannym@scratchpost.org>
Thu, 4 Jul 2019 00:21:24 +0000 (02:21 +0200)
committerJan Nieuwenhuizen <janneke@gnu.org>
Mon, 9 Sep 2019 14:04:14 +0000 (16:04 +0200)
* include/signal.h (sigset_t): Increase size.
* lib/linux/signal.c (signal): Use new sigset_t.

include/signal.h
lib/linux/signal.c

index 121d302755a3d7a8f48c004a50150e875df8bb53..877b2d5504ca6b715ce2e0fad4391f1a7c4c2f63 100644 (file)
 #include_next <signal.h>
 #else //! SYSTEM_LIBC
 
+#define _NSIG 64
 
-typedef long sigset_t;
+#define _SIGSET_NITEMS (_NSIG / (8 * sizeof(unsigned long)))
+
+typedef struct {
+  unsigned long items[_SIGSET_NITEMS];
+} sigset_t;
 typedef long stack_t;
 
 #include <sys/types.h>
index 19f09d643303e953dda78edca177f5c89c34d8f2..6d95b6abdaeb258dc4959fca73c5bc2304e8f42e 100644 (file)
@@ -41,12 +41,16 @@ signal (int signum, sighandler_t action)
 #if __i386__
   return _sys_call2 (SYS_signal, signum, action);
 #else
-  static struct sigaction setup_action = { -1 };
+  static struct sigaction setup_action = { 0 };
   static struct sigaction old = { 0 };
+  unsigned short bitindex;
+  unsigned short itembitcount;
 
   setup_action.sa_handler = action;
   setup_action.sa_restorer = _restorer;
-  setup_action.sa_mask = __sigmask (signum);
+  bitindex = signum - 1;
+  itembitcount = 8 * sizeof(setup_action.sa_mask.items[0]);
+  setup_action.sa_mask.items[bitindex / itembitcount] = 1 << (bitindex % itembitcount);
   old.sa_handler = SIG_DFL;
   setup_action.sa_flags = SA_RESTORER | SA_RESTART;
   int r = _sys_call4 (SYS_rt_sigaction, signum, &setup_action, &old, sizeof (sigset_t));