[Date Prev][Date Next]
(ITS#5248) non-atomic signal variables
Full_Name: Hallvard B Furuseth
Submission from: (NULL) (22.214.171.124)
Submitted by: hallvard
Some non-atomic variables are used both outside and inside signal handlers:
static int gotintr;
static int abcan;
static volatile int waking;
(used via WAKE_LISTENER in signal handler)
static int gotsig;
They need to be volatile sig_atomic_t.
That can be signed or unsigned char, so abcan must be set to some
#define in range 0..127 instead of -1.
Two more problems:
WAKE_LISTENER will not be correct anyway since it does '++waking' (not
atomic) and is called both inside and outside a signal handler.
The !NO_THREADS version is OK.
For that matter, behavior is only defined when the signal handler
_writes_ a volatile sig_atomic_t, not when it _reads_ it:
Dunno what the problem is, or if it is worse than variables
accessed by threads. I don't see anything to do about it either.