Perl SIG versus signal handling

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
Hi. Er...

I've got this script which uses MIDI::ALSA, and installs a
signal-handler at the Perl-level,   $SIG = \&myhandler;
then creates an ALSA client and so on, then listens for
the next event with   snd_seq_event_input(seq_handle, &ev)

When it receives an ALSA event it returns it just fine :-)

But whenever I send the process an INT signal, either from ^C at
the keyboard or from a different xterm, I get Segmentation fault
and my Perl signal handler doesn't get invoked :-( .

strace reveals nothing to me, it's just waiting to read
from some filehandle and then: Segmentation fault

In /var/log/messages I get a message every time saying:

segfault at 0 ip b74fba3b sp bfd52c80 error 4 in[b74f6000+9000]

So the INT signal causes to segfault. But if I don't install
a Perl signal-handler then the script Quits in an orderly manner,
though of course then it doesn't save my midi file before quitting.
But a fairly similar setup in  arecordmidi.c  works fine, with:
  signal(SIGINT, sighandler);
at the C-level.  There seems to be a conflict between signal-handling and Perl signal-handling.

I've asked as well, in case it's a known
issue, but I thought I'd better ask here in case it's a known
Perl %SIG issue.   Should  b74f6000+9000  tell me anything ?

Regards,  Peter

Peter Billam

Re: Perl SIG versus signal handling

Quoted text here. Click to load it

Apologies, apologies... is not part of ALSA (which is
libasound) it's part of my own MIDI::ALSA, and I was failing
to check that the return code of snd_seq_event_input() was not
negative.  I awoke at half past midnight knowing the answer...
Bug now fixed :-)

Sorry to bother,
Regards,  Peter

Peter Billam

Site Timeline