How can you extract SIGINFO information for signal trap subroutines? Here's a snippet of what it would include:
The siginfo_t parameter to sa_sigaction is a struct with the fo +llowing elements siginfo_t { int si_signo; /* Signal number */ int si_errno; /* An errno value */ int si_code; /* Signal code */ pid_t si_pid; /* Sending process ID */ uid_t si_uid; /* Real user ID of sending proce +ss */ int si_status; /* Exit value or signal */ clock_t si_utime; /* User time consumed */ clock_t si_stime; /* System time consumed */ sigval_t si_value; /* Signal value */ int si_int; /* POSIX.1b signal */ void * si_ptr; /* POSIX.1b signal */ void * si_addr; /* Memory location which caused +fault */ int si_band; /* Band event */ int si_fd; /* File descriptor */ }
I've digged and digged around on the net for something that works, but can't find anything. The closest I've found is something like this:
use POSIX; sub hup { print "hup(@_)\n"; for my $k (sort keys %{$_[1]}) { print "$k $_[1]->{$k}\n"; } } my $newaction=POSIX::SigAction->new(\&hup, 0, SA_SIGINFO); sigaction(SIGHUP, $newaction); print "I am $$\n"; kill HUP, $$;
However, it doesn't work on the Knoppix Linux distro that I tried. It acts like a typical $SIG trap, and doesn't return anything except the signal type.

Also, is there any reason why this sort of thing wouldn't be built into Perl in the first place? It would seem like a well requested thing to at least know which process ID sent a TERM signal, for example.


In reply to SIGINFO information in Perl by SineSwiper

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.