This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author neologix
Recipients jgehrcke, neologix, pitrou, sdaoden, vstinner
Date 2014-05-23.18:32:35
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <CAH_1eM36j4+-wHNVxwDPsNiERMtFB+z-s-UUw3Zxsuu=L8sq2w@mail.gmail.com>
In-reply-to <1400839060.2.0.7667288716.issue20584@psf.upfronthosting.co.za>
Content
> Jan-Philip Gehrcke added the comment:
>
> Currently the docs say that signal.NSIG is "One more than the number of the highest signal number." ("https://docs.python.org/3.4/library/signal.html#signal.NSIG).
>
> In case of FreeBSD's _SIG_MAXSIG (128) the documentation is still wrong: the highest signal value MAX is 126 (see http://bugs.python.org/issue20584#msg210892). According to the docs, NSIG should then be 127.

Yeah, but it doesn't matter.
We shouldn't be exposing this constant in the first place, all that
matters is that we accept all valid signals, and we don't crash whe
passing an invalid once (ssee below).

> Steffen Daode Nurpmeso added the comment:
>
>   #ifdef NSIG_MAX
>   # undef NSIG
>   # define NSIG           NSIG_MAX
>   #elif !defined NSIG
>   # define NSIG           ((sizeof(sigset_t) * 8) - 1)
>   #endif
>
> should do the trick for Python on any POSIX system?

This assumes that sigset_t is implemented as a raw bitmap, which isn't
documented (is could be implemented by an arbitrary  data structure).
On the other hand, it's really really likely, and should guarantee
that sigset & Co don't crash on too large values (or write to
arbitrary memory locations like fd_set when passed fd > FD_SETSIZE).

So I think we should go for the above patch (Steffen's), with a doc
update saying that "NSIG is a value larger than the largest signals".
If the OS headers don't provide it, it's not our business to try to
infer it.
History
Date User Action Args
2014-05-23 18:32:36neologixsetrecipients: + neologix, pitrou, vstinner, jgehrcke, sdaoden
2014-05-23 18:32:36neologixlinkissue20584 messages
2014-05-23 18:32:35neologixcreate