Text descriptions of signal codes?

Discussion in 'Perl Misc' started by allenjo5@mail.northgrum.com, Jul 27, 2006.

  1. Guest

    Is there as easy a way to get the textual description of a process
    signal code in perl as there is to get the textual description of a
    system call error code? For instance, for an errno of 24, just set $!
    to 24 and use it as a string:

    $ perl -le '$!=24; print $!'
    The process file table is full.

    Is there something equivalent for getting the text meaning of signal
    code 24 (SIGXCPU) without having to parse signal.h? Yeah I can do
    that readily enough, but was expecting perl to provide an easier
    method. So far, I haven't found the trick.
    , Jul 27, 2006
    #1
    1. Advertising

  2. Guest

    A. Sinan Unur wrote:

    > use Config;
    > use List::MoreUtils 'first_index';
    >
    > my $sig_idx = first_index { $_ == 24 } split / /, $Config{sig_num};
    > if ( $sig_idx >= 0 ) {
    > my @sig_name = split / /, $Config{sig_name};
    > print $sig_name[$sig_idx], "\n";
    > }


    Yes, that will get me "SIGXCPU" but I was looking for an english
    description like "cpu time limit exceeded". Sorry if I wasn't clear
    about that. I guess parsing signal.h isn't so bad...
    , Jul 27, 2006
    #2
    1. Advertising

  3. Ben Morrow Guest

    Quoth :
    >
    > A. Sinan Unur wrote:
    >
    > > use Config;
    > > use List::MoreUtils 'first_index';
    > >
    > > my $sig_idx = first_index { $_ == 24 } split / /, $Config{sig_num};
    > > if ( $sig_idx >= 0 ) {
    > > my @sig_name = split / /, $Config{sig_name};
    > > print $sig_name[$sig_idx], "\n";
    > > }

    >
    > Yes, that will get me "SIGXCPU" but I was looking for an english
    > description like "cpu time limit exceeded". Sorry if I wasn't clear
    > about that. I guess parsing signal.h isn't so bad...


    At least on my system, this stuff isn't in signal.h. You need to read
    the sys_siglist array. I wrote a tiny XS module to do just that, which I
    guess I could upload to CPAN if that would help you...

    A major problem (IMHO) is that there is no way of i18ning[0] these things.

    Ben

    --
    I've seen things you people wouldn't believe: attack ships on fire off
    the shoulder of Orion; I watched C-beams glitter in the dark near the
    Tannhauser Gate. All these moments will be lost, in time, like tears in rain.
    Time to die.
    Ben Morrow, Jul 27, 2006
    #3
  4. -berlin.de Guest

    <> wrote in comp.lang.perl.misc:
    > Is there as easy a way to get the textual description of a process
    > signal code in perl as there is to get the textual description of a
    > system call error code? For instance, for an errno of 24, just set $!
    > to 24 and use it as a string:
    >
    > $ perl -le '$!=24; print $!'
    > The process file table is full.
    >
    > Is there something equivalent for getting the text meaning of signal
    > code 24 (SIGXCPU) without having to parse signal.h? Yeah I can do
    > that readily enough, but was expecting perl to provide an easier
    > method. So far, I haven't found the trick.


    The Config module has the table you want. Adapted from "perldoc
    perlipc":

    use Config;
    defined $Config{sig_name} || die "No sigs?";

    my ( @signame, %signo);
    my $i = 0;
    foreach my $name ( split(' ', $Config{sig_name}) ) {
    $signo{$name} = $i;
    $signame[$i] = $name;
    $i++;
    }

    Anno
    -berlin.de, Jul 28, 2006
    #4
  5. Guest

    Ben Morrow wrote:

    > At least on my system, this stuff isn't in signal.h. You need to read
    > the sys_siglist array. I wrote a tiny XS module to do just that, which I
    > guess I could upload to CPAN if that would help you...


    Hmmm, yes, I guess access to the sys_siglist array is what I want.
    There's also the psignal() system call that provides the same info.
    Both seem to be in the standard C library (on AIX anyway). I don't
    want it bad enough to be the sole reason that you upload such a CPAN
    module, but if you did I wouldn't mind :)

    John.
    , Jul 29, 2006
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. VB Programmer

    Question: Function descriptions in yellow

    VB Programmer, Aug 27, 2003, in forum: ASP .Net
    Replies:
    2
    Views:
    343
    Ken Cox [Microsoft MVP]
    Aug 28, 2003
  2. JR
    Replies:
    2
    Views:
    304
    Hans Kesting
    Dec 12, 2003
  3. bcryor

    VBTP Descriptions

    bcryor, Sep 25, 2004, in forum: Java
    Replies:
    0
    Views:
    406
    bcryor
    Sep 25, 2004
  4. Hardeep Rakhra
    Replies:
    10
    Views:
    681
    Hardeep Rakhra
    Feb 19, 2004
  5. Replies:
    2
    Views:
    2,821
    Malcolm
    Aug 20, 2005
Loading...

Share This Page