SIGUNUSED

View: New views
6 Messages — Rating Filter:   Alert me  

SIGUNUSED

by Alexander Best :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

some programmers tend to do the following in their apps to install a standard
handler for all signals (mostly SIG_IGN):

int counter;

for (counter = 1; counter < SIGUNUSED; counter++)
    signal(counter, SIG_IGN);

any objections if we also have SIGUNUSED in our signal.h? seems like a
reasonable addition. since the highest signal number (excluding
SIGRT[MIN|MAX]) is SIGTHR with 32 we could add

#define SIGUNUSED 33

alex.
_______________________________________________
freebsd-hackers@... mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@..."

Re: SIGUNUSED

by Jilles Tjoelker :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Fri, Nov 06, 2009 at 10:33:57PM +0100, Alexander Best wrote:
> some programmers tend to do the following in their apps to install a standard
> handler for all signals (mostly SIG_IGN):

> int counter;

> for (counter = 1; counter < SIGUNUSED; counter++)
>     signal(counter, SIG_IGN);

> any objections if we also have SIGUNUSED in our signal.h? seems like a
> reasonable addition. since the highest signal number (excluding
> SIGRT[MIN|MAX]) is SIGTHR with 32 we could add

> #define SIGUNUSED 33

That code is wrong, SIGUNUSED is not meant to be used in that way. It
seems to originate from Linux, but it is not available on all
architectures there, and where it is available it is a valid signal.

Also, ignoring all signals tends not to be a good idea. For traps, it's
either the same as the default action (FreeBSD unless admin sets
kern.forcesigexit=0), or it is an infinite loop or other undefined
behaviour.

--
Jilles Tjoelker
_______________________________________________
freebsd-hackers@... mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@..."

Re: SIGUNUSED

by Alexander Best :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Jilles Tjoelker schrieb am 2009-11-06:
> On Fri, Nov 06, 2009 at 10:33:57PM +0100, Alexander Best wrote:
> > some programmers tend to do the following in their apps to install
> > a standard
> > handler for all signals (mostly SIG_IGN):

> > int counter;

> > for (counter = 1; counter < SIGUNUSED; counter++)
> >     signal(counter, SIG_IGN);

> > any objections if we also have SIGUNUSED in our signal.h? seems
> > like a
> > reasonable addition. since the highest signal number (excluding
> > SIGRT[MIN|MAX]) is SIGTHR with 32 we could add

> > #define SIGUNUSED 33

> That code is wrong, SIGUNUSED is not meant to be used in that way. It
> seems to originate from Linux, but it is not available on all
> architectures there, and where it is available it is a valid signal.

> Also, ignoring all signals tends not to be a good idea. For traps,
> it's
> either the same as the default action (FreeBSD unless admin sets
> kern.forcesigexit=0), or it is an infinite loop or other undefined
> behaviour.

oh. i see. i'm not a linux user. that's why i thought SIGUNUSED was designed
exactly for that purpose.

as a side not:
our own easyedit does exactly what you said wasn't a good programming style.
;) check line 554 of contrib/ee/ee.c:

        for (counter = 1; counter < 24; counter++)
                signal(counter, SIG_IGN);

cheers.
alex
_______________________________________________
freebsd-hackers@... mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@..."

Re: SIGUNUSED

by Nate Eldredge-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Sat, 7 Nov 2009, Alexander Best wrote:

> Jilles Tjoelker schrieb am 2009-11-06:
>> On Fri, Nov 06, 2009 at 10:33:57PM +0100, Alexander Best wrote:
>>> some programmers tend to do the following in their apps to install
>>> a standard
>>> handler for all signals (mostly SIG_IGN):
>
>>> int counter;
>
>>> for (counter = 1; counter < SIGUNUSED; counter++)
>>>     signal(counter, SIG_IGN);

>> That code is wrong, SIGUNUSED is not meant to be used in that way. It
>> seems to originate from Linux, but it is not available on all
>> architectures there, and where it is available it is a valid signal.

> oh. i see. i'm not a linux user. that's why i thought SIGUNUSED was designed
> exactly for that purpose.

I think that's what NSIG was for.  But it seems to be BSD-specific, and
perhaps obsolecent.

--

Nate Eldredge
nate@...
_______________________________________________
freebsd-hackers@... mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@..."

Re: SIGUNUSED

by Eugene Grosbein-6 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Sat, Nov 07, 2009 at 03:17:49AM +0100, Alexander Best wrote:

> as a side not:
> our own easyedit does exactly what you said wasn't a good programming style.
> ;) check line 554 of contrib/ee/ee.c:
>
>         for (counter = 1; counter < 24; counter++)
>                 signal(counter, SIG_IGN);

Easy Editor is contributed software (now lives in contrib/).

Such naive signgal handling had already hurt it in the past,
f.e. plain ignore of SIGTTIN, SIGTTOU without sanity checks for
STDIN_FILENO, STDOUT_FILENO made it CPU hog for 'ee file &'
or 'ee </dev/null' in early versions.

Eugene Grosbein
_______________________________________________
freebsd-hackers@... mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@..."

Re: SIGUNUSED

by Dag-Erling Smørgrav :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Jilles Tjoelker <jilles@...> writes:
> That code is wrong, SIGUNUSED is not meant to be used in that way. It
> seems to originate from Linux, but it is not available on all
> architectures there, and where it is available it is a valid signal.

>From signal(7):

       SIGUNUSED    -,31,-     Term    Unused signal (will be SIGSYS)

and there is no higher-numbered signal, but the -s mean it is not
available on at alpha, sparc64 or mips.  There is no reference to it in
any section 2 or 3 man page.

DES
--
Dag-Erling Smørgrav - des@...
_______________________________________________
freebsd-hackers@... mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@..."