Change request: return value from 'trap'

I notice that in ruby-1.6.8, the return value from ‘trap’ is nil if the
current signal is either DEFAULT or IGNORE.

What I’d like to be able to do is to override and then later restore a
signal handler, like this:

oldsig = trap(‘SIGUSR1’) { … stuff … }

trap(‘SIGUSR1’,oldsig)

However, it seems that passing nil is the same as ‘IGNORE’, so this will
wrongly change ‘DEFAULT’ into ‘IGNORE’.

If I know that I want default handling then I can do:

trap(‘SIGUSR1’,oldsig || ‘DEFAULT’)

But wouldn’t it be better if trap returned ‘DEFAULT’ or ‘IGNORE’ as the
previous state of the signal handler?

Regards,

Brian.

Hi,

···

In message “Change request: return value from ‘trap’” on 03/03/25, Brian Candler B.Candler@pobox.com writes:

I notice that in ruby-1.6.8, the return value from ‘trap’ is nil if the
current signal is either DEFAULT or IGNORE.

What I’d like to be able to do is to override and then later restore a
signal handler, like this:

oldsig = trap(‘SIGUSR1’) { … stuff … }

trap(‘SIGUSR1’,oldsig)

However, it seems that passing nil is the same as ‘IGNORE’, so this will
wrongly change ‘DEFAULT’ into ‘IGNORE’.

If I know that I want default handling then I can do:

trap(‘SIGUSR1’,oldsig || ‘DEFAULT’)

But wouldn’t it be better if trap returned ‘DEFAULT’ or ‘IGNORE’ as the
previous state of the signal handler?

Sounds nice. Taken.

						matz.