Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Text descriptions of signal codes?

Reply
Thread Tools

Text descriptions of signal codes?

 
 
allenjo5@mail.northgrum.com
Guest
Posts: n/a
 
      07-27-2006
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.

 
Reply With Quote
 
 
 
 
allenjo5@mail.northgrum.com
Guest
Posts: n/a
 
      07-27-2006

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...

 
Reply With Quote
 
 
 
 
Ben Morrow
Guest
Posts: n/a
 
      07-27-2006

Quoth http://www.velocityreviews.com/forums/(E-Mail Removed):
>
> 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. (E-Mail Removed)
 
Reply With Quote
 
anno4000@radom.zrz.tu-berlin.de
Guest
Posts: n/a
 
      07-28-2006
<(E-Mail Removed)> 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
 
Reply With Quote
 
allenjo5@mail.northgrum.com
Guest
Posts: n/a
 
      07-29-2006

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.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
IOS descriptions and IOS for the 3560 Harkin Cisco 1 10-13-2005 02:52 PM
VBTP Descriptions bcryor Java 0 09-25-2004 06:07 PM
Creating a Products List with Descriptions and Left Floated Images? Hardeep Rakhra HTML 10 02-19-2004 12:50 AM
How do I add descriptions to public functions? JR ASP .Net 2 12-12-2003 12:54 PM
Question: Function descriptions in yellow VB Programmer ASP .Net 2 08-28-2003 02:49 AM



Advertisments