home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / os / linux / 25108 < prev    next >
Encoding:
Text File  |  1993-01-22  |  3.1 KB  |  88 lines

  1. Newsgroups: comp.os.linux
  2. Path: sparky!uunet!mnemosyne.cs.du.edu!pavo.csi.cam.ac.uk!cam-orl!iwj
  3. From: ijackson@nyx.cs.du.edu (Ian Jackson)
  4. Subject: bug in CVS-1.3 or <signal.h>:__sigmask
  5. Message-ID: <1993Jan22.142240.16071@infodev.cam.ac.uk>
  6. Followup-To: comp.os.linux
  7. Summary: bug, either in include file or in cvs
  8. Sender: iwj@cam-orl.co.uk
  9. Nntp-Posting-Host: leek.cam-orl.co.uk
  10. Reply-To: ijackson@nyx.cs.du.edu (Ian Jackson)
  11. Organization: Olivetti Research Ltd
  12. Date: Fri, 22 Jan 1993 14:40:12 GMT
  13. Lines: 73
  14.  
  15. I don't know if anybody else has tried to install CVS with recent-ish
  16. header files, but anybody doing so (and also Hlu!) might be interested
  17. to know the following:
  18.  
  19. CVS tries
  20.         for (i=1; sigismember(&set,i)==1; i++) { ... }
  21. where set has been initialised using sigfillset.
  22.  
  23. The definition of sigismember in <signal.h> involves anding the set
  24. with __sigmask(i), which is defined (also in <signal.h>) as
  25.         #define __sigmask(sig)  (1 << ((sig) - 1))
  26.  
  27. Since sigfillset makes a word with all bits set (NSIG is 32), and
  28. shifting by greater than or equal to the size of a word produces
  29. implementation defined behaviour (K&R2 A7.8, p206; using gcc-2.3.3 on
  30. a 386 results in the shift distance being reduced modulo 32 before the
  31. shift) the result is an infinite loop.
  32.  
  33. Unfortunately I don't have access to any POSIX documentation to find
  34. out which of <signal.h> and CVS is right (ie, whether CVS is allowed
  35. to pass to sigismember a signal number which is out of range), so I
  36. don't know which file to patch.
  37.  
  38. In the meantime I've changed both, for safety's sake. Here are the two
  39. patches, first to <signal.h> and then to {your-cvs-dir}/lib/sighandle.c:
  40.  
  41. NB Please DON'T just run this article through patch - it won't work right !
  42.  
  43. *** signal.h~   Mon Nov 23 17:30:12 1992
  44. --- signal.h    Thu Jan 21 21:45:27 1993
  45. ***************
  46. *** 75,81 ****
  47.   
  48.   
  49.   /* Return a mask that includes SIG only.  */
  50. ! #define __sigmask(sig)  (1 << ((sig) - 1))
  51.   
  52.   extern sigset_t       __sigsetmask __P ((sigset_t __mask));
  53.   extern sigset_t       __siggetmask __P ((void));
  54. --- 75,81 ----
  55.   
  56.   
  57.   /* Return a mask that includes SIG only.  */
  58. ! #define __sigmask(sig)  (sig <= _NSIG ? 1 << ((sig) - 1) : 0)
  59.   
  60.   extern sigset_t       __sigsetmask __P ((sigset_t __mask));
  61.   extern sigset_t       __siggetmask __P ((void));
  62.  
  63. *** lib/sighandle.c.~1~ Fri Jan 22 13:52:43 1993
  64. --- lib/sighandle.c     Fri Jan 22 13:53:23 1993
  65. ***************
  66. *** 112,118 ****
  67.   
  68.   #ifdef POSIX
  69.         (void) sigfillset(&sigset_test);
  70. !       for (i = 1; sigismember(&sigset_test, i) == 1; i++)
  71.                 ;
  72.         if (i < SIGMAX)
  73.                 i = SIGMAX;
  74. --- 112,118 ----
  75.   
  76.   #ifdef POSIX
  77.         (void) sigfillset(&sigset_test);
  78. !       for (i = 1; i <= NSIG && sigismember(&sigset_test, i) == 1; i++)
  79.                 ;
  80.         if (i < SIGMAX)
  81.                 i = SIGMAX;
  82.  
  83. --
  84. Ian Jackson  iwj@cam-orl.co.uk ..!uknet!cam-orl!iwj  These opinions are my own.
  85. Olivetti Research Ltd, Old Addenbrookes Site, Trumpington St, Cambridge, UK;
  86. Home: 35 Molewood Close, Cambridge, CB4 3SR; +44 223 327029.     +44 223 343398
  87. Email also via: ijackson@nyx.cs.du.edu   PGP2 public key available on request
  88.