lwp: Rewrite signal wait code for portability and safety

LWP's use of sigset_t is problematic.

To iterate over a sigset_t, it uses NSIG, which is not portable: BSD
and System V provide it, but it's not POSIX.

To record signals caught, it updates a sigset_t variable from a signal
handler.  The variable isn't volatile, because we'd have to cast away
volatile for sigaddset().

Replace sigset_t by an array of signal numbers terminated with 0.

Since lwpInitSigWait() needs to store the signal set for
lwpCatchAwaitedSig() anyway, there is no need to pass it to
lwpSigWait().  Drop its parameter.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
This commit is contained in:
Markus Armbruster 2020-12-27 09:36:54 +01:00
parent bfb558dee3
commit 8a1d9fbb4b
5 changed files with 68 additions and 60 deletions

View file

@ -28,13 +28,12 @@
* lwpint.h: lwp internal structures
*
* Known contributors to this file:
* Markus Armbruster, 2004-2009
* Markus Armbruster, 2004-2020
*/
#ifndef LWPINT_H
#define LWPINT_H
#include <signal.h>
#include <time.h>
#include <ucontext.h>
@ -82,7 +81,7 @@ void lwpEntryPoint(void);
void lwpInitSelect(struct lwpProc *);
void lwpWakeupSleep(void);
void lwpSelect(void *);
void lwpInitSigWait(sigset_t *);
void lwpInitSigWait(int[]);
void lwpSigWakeup(void);
void lwpStatus(struct lwpProc *, char *, ...)
ATTRIBUTE((format (printf, 2, 3)));