Subject: Re: lib/297: sigismember bug?
To: J.T. Conklin <jconklin@netcom.com>
From: Chris G. Demetriou <cgd@alpha.bostic.com>
List: netbsd-bugs
Date: 06/21/1994 00:45:51
> > >Description:
> > 	sigismember always returns true(1)
> > 	
> > >Fix:
> > 	The problem appears to be in the macro call.  If I compile cvs with the
> > 	macro commented out and use the function call everything appears 
> > 	to work correctly.  I checked the macro call for sigismember() and 
> > 	it looks correct but possible because sigset_t is a 32bit int 
> > 	because the way the check is done it could always be true.
> 
> It's not strictly a bug, POSIX.1 gives the implementor the option of not 
> checking to see if the signal is in range.

For those of you who care, the .1 wording is really evil for
this one.  It reads as follows:

[ 3.3.3 talks about the sigsetopts ]

> 3.3.3.3 Returns
>
> Upon successful completion, the sigismember() function returns a value
> of one if the specified signal is a member of the specified set, or a
> value of zero if it is not.  Upon successful completion, the other
> functions return a value of zero.  For all of the above functions, if
> an error is detected, a value of -1 is return and /errno/ is set to
> indicate the error.


In other words, if you never check for an out of range signal
number, you never detect an out of range signal number.  If you
never detect an out of range signal number, you don't have to return
-1.

There's also the other tack that can be taken, and one which i've
espoused in the past:  If the sinal number argument does _not_
denote a valid signal, then it can't be in the set, so you should
return 0. However, that isn't perfect, because, of course, the POSIX
wording only says that the thing specified is a signal...


You can see how this'd get hairy.  Consider the conversation:
"well, we didn't notice an error, so we don't have to return -1."
"but, the signal mentioned is not a member of the specified set,
 so you at least have to return 0!"
"no, not really; the thing mentioned was not even a signal, so it's
 just an error that we didn't detect.  And POSIX says nothing about
 what we can return in the case of an _undetected_ error!"


cute, eh?


cgd

------------------------------------------------------------------------------