I am trying to set up a routine to trap signals so that I can pass it to
a sub that will act on the signals and it does not seem to be
functioning as I would think.

SAMPLE: 
I will admit some of the code was taken from the camel book.  :)  I do
have use strict on.

my $name = "\n";
my $i = 0;

defined $Config{sig_name} || die "The Stupid System does not support
Signals?";
foreach $name(split(' ', $Config{sig_name}))
 {
   $Config::signo{$name} = $i;
   $Config::signame[$i] = $name;
  #print "$name:$i \t => SIG{'$name'} = \&sigcat\n";
   $SIG{'$name'} = \&sigcat;
   $i++;
 }

Now I do have an while (1){}; setup so that I can test the break.  Using
the above code I do not seem to enter my sub sigcat I do not see my
'special' signal catch message if I press ^C.  HOWEVER, if I add the
following lines:

$SIG{'INT'} = \&sigcat;
$SIG{'HUP'} = \&sigcat;
$SIG{'STOP'} = \&sigcat;
$SIG{'ABRT'} = \&sigcat;
$SIG{'TERM'} = \&sigcat;

It does break out and lets me know that it received a HUP. 

If I take the single quote ' off of the $name in the loop I get a
segmentation fault so I guess I need the quotes.

Can anybody tell me what is wrong with the loop and why it is not
working?  Also if I uncomment the line:
#print "$name:$i \t => SIG{'$name'} = \&sigcat\n";
It appears to be running the correct set routine as in the 5 I have
shown above.  I know I must have something simple but I just can not see
what it is...
-- 
Leif Ericksen <[EMAIL PROTECTED]>


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to