4.2 sigblock manual page is vague (wrong?)

muller at sdccsu3.UUCP muller at sdccsu3.UUCP
Sat Mar 31 06:12:06 AEST 1984


The manual page for sigblock states "Signal i is blocked if the
i-th bit in mask is a 1".
So I blindly (wrongly) assumed that the following code fragment would
block SIGALRM (alarm 15):

oldmask = sigblock(1 << SIGALRM);

WRONG! That blocks SIGTERM (16) not SIGALRM (15). What the problem is that
I was counting the bits calling the least significant bit the 0th bit.
The least significant bit for the purposes of sigblock is the 1st bit.

The correct code fragment for blocking SIGALRM is:

oldmask = sigblock(1 << (SIGALRM - 1));

Keith Muller



More information about the Comp.unix.wizards mailing list