in reply to Re: Signal Handler
in thread Signal Handler

Thanks for our reply. I executed the code that you posted.
But I got only the signal name.
$VAR1 = [ "INT" ]; Sender PID: Own PID: 2784

I am using debian, and my system supports sigaction(2). Now I need to know what will be the problem. Please help.

Replies are listed 'Best First'.
Re^3: Signal Handler
by almut (Canon) on Dec 06, 2008 at 08:11 UTC

    Sorry, forgot to mention explicitly that this only works starting with Perl 5.10.0 — AFAIK, older versions only ever provide the signal name (I get the same output as you with 5.8.8).

    Update: FWIW, this is the respective code snippet from mg.c (line 2854) in the Perl 5.10.0 sources:

    #if defined(HAS_SIGACTION) && defined(SA_SIGINFO) { struct sigaction oact; if (sigaction(sig, 0, &oact) == 0 && oact.sa_flags & SA_SIGINFO) +{ if (sip) { HV *sih = newHV(); SV *rv = newRV_noinc((SV*)sih); /* The siginfo fields signo, code, errno, pid, uid, * addr, status, and band are defined by POSIX/SUSv3. */ (void)hv_stores(sih, "signo", newSViv(sip->si_signo)); (void)hv_stores(sih, "code", newSViv(sip->si_code)); #if 0 /* XXX TODO: Configure scan for the existence of these, but even + that does not help if the SA_SIGINFO is not implemented according to + the spec. */ hv_stores(sih, "errno", newSViv(sip->si_errno)); hv_stores(sih, "status", newSViv(sip->si_status)); hv_stores(sih, "uid", newSViv(sip->si_uid)); hv_stores(sih, "pid", newSViv(sip->si_pid)); hv_stores(sih, "addr", newSVuv(PTR2UV(sip->si_addr))) +; hv_stores(sih, "band", newSViv(sip->si_band)); #endif EXTEND(SP, 2); PUSHs((SV*)rv); PUSHs(newSVpvn((char *)sip, sizeof(*sip))); } } } #endif

    I can't find any entry in the Changes file when this has been added, but it's definitely not there in 5.8.8.   (Note the "#if 0 /* XXX TODO:...", btw, which wraps the "pid" code.)

      Hi almut,

      Thanks, now I got it. You also gave me an insight on XS. Thanks.