home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.os.linux
- Path: sparky!uunet!mnemosyne.cs.du.edu!pavo.csi.cam.ac.uk!cam-orl!iwj
- From: ijackson@nyx.cs.du.edu (Ian Jackson)
- Subject: bug in CVS-1.3 or <signal.h>:__sigmask
- Message-ID: <1993Jan22.142240.16071@infodev.cam.ac.uk>
- Followup-To: comp.os.linux
- Summary: bug, either in include file or in cvs
- Sender: iwj@cam-orl.co.uk
- Nntp-Posting-Host: leek.cam-orl.co.uk
- Reply-To: ijackson@nyx.cs.du.edu (Ian Jackson)
- Organization: Olivetti Research Ltd
- Date: Fri, 22 Jan 1993 14:40:12 GMT
- Lines: 73
-
- I don't know if anybody else has tried to install CVS with recent-ish
- header files, but anybody doing so (and also Hlu!) might be interested
- to know the following:
-
- CVS tries
- for (i=1; sigismember(&set,i)==1; i++) { ... }
- where set has been initialised using sigfillset.
-
- The definition of sigismember in <signal.h> involves anding the set
- with __sigmask(i), which is defined (also in <signal.h>) as
- #define __sigmask(sig) (1 << ((sig) - 1))
-
- Since sigfillset makes a word with all bits set (NSIG is 32), and
- shifting by greater than or equal to the size of a word produces
- implementation defined behaviour (K&R2 A7.8, p206; using gcc-2.3.3 on
- a 386 results in the shift distance being reduced modulo 32 before the
- shift) the result is an infinite loop.
-
- Unfortunately I don't have access to any POSIX documentation to find
- out which of <signal.h> and CVS is right (ie, whether CVS is allowed
- to pass to sigismember a signal number which is out of range), so I
- don't know which file to patch.
-
- In the meantime I've changed both, for safety's sake. Here are the two
- patches, first to <signal.h> and then to {your-cvs-dir}/lib/sighandle.c:
-
- NB Please DON'T just run this article through patch - it won't work right !
-
- *** signal.h~ Mon Nov 23 17:30:12 1992
- --- signal.h Thu Jan 21 21:45:27 1993
- ***************
- *** 75,81 ****
-
-
- /* Return a mask that includes SIG only. */
- ! #define __sigmask(sig) (1 << ((sig) - 1))
-
- extern sigset_t __sigsetmask __P ((sigset_t __mask));
- extern sigset_t __siggetmask __P ((void));
- --- 75,81 ----
-
-
- /* Return a mask that includes SIG only. */
- ! #define __sigmask(sig) (sig <= _NSIG ? 1 << ((sig) - 1) : 0)
-
- extern sigset_t __sigsetmask __P ((sigset_t __mask));
- extern sigset_t __siggetmask __P ((void));
-
- *** lib/sighandle.c.~1~ Fri Jan 22 13:52:43 1993
- --- lib/sighandle.c Fri Jan 22 13:53:23 1993
- ***************
- *** 112,118 ****
-
- #ifdef POSIX
- (void) sigfillset(&sigset_test);
- ! for (i = 1; sigismember(&sigset_test, i) == 1; i++)
- ;
- if (i < SIGMAX)
- i = SIGMAX;
- --- 112,118 ----
-
- #ifdef POSIX
- (void) sigfillset(&sigset_test);
- ! for (i = 1; i <= NSIG && sigismember(&sigset_test, i) == 1; i++)
- ;
- if (i < SIGMAX)
- i = SIGMAX;
-
- --
- Ian Jackson iwj@cam-orl.co.uk ..!uknet!cam-orl!iwj These opinions are my own.
- Olivetti Research Ltd, Old Addenbrookes Site, Trumpington St, Cambridge, UK;
- Home: 35 Molewood Close, Cambridge, CB4 3SR; +44 223 327029. +44 223 343398
- Email also via: ijackson@nyx.cs.du.edu PGP2 public key available on request
-