Subject: Problems with sigismember macro?
To: None <>
From: None <>
List: current-users
Date: 09/14/1994 15:09:36
I was trying to compile up cvs today using the Aug. 1 binary snapshot.
It compiles ok after some tweaking but would just go into an infinite
loop when run.

This code is what was causing it:

        (void) sigfillset(&sigset_test);
        for (i = 1; sigismember(&sigset_test, i) == 1; i++)

Basically it's trying a brute force method to determine the largest valid
signal number presuming they are in sequence. Now this works perfectly fine
if I add a #undef sigismember above that to make sure it uses the
library call. The reason it breaks, if the macro from <signal.h> is :

#define sigismember(set, signo) ((*(set) & (1 << ((signo) - 1))) != 0)

This won't work because sigismember is supposed to return -1 on error's such
as invalid arguments and such. It's also supposed to return 0 on signals
that aren't set in the mask. Since signo is getting passed in values that
are larger than 32 (the number of bits in an int) the results from
that shift are just undefined and from what I can see always return true.

My suggestion here is to just remove the sigismember macro since it can't
possibly do everything sigismember is supposed to do. The other sig macro's
look fine however.