Actually not quite what you thought on the output... $ ./myt.pl ZERO:0 => SIG{'ZERO'} = &sigcat HUP:1 => SIG{'HUP'} = &sigcat INT:2 => SIG{'INT'} = &sigcat QUIT:3 => SIG{'QUIT'} = &sigcat ILL:4 => SIG{'ILL'} = &sigcat TRAP:5 => SIG{'TRAP'} = &sigcat ABRT:6 => SIG{'ABRT'} = &sigcat BUS:7 => SIG{'BUS'} = &sigcat FPE:8 => SIG{'FPE'} = &sigcat KILL:9 => SIG{'KILL'} = &sigcat
Also if I use the double quote as opposed to a single quote in: SIG{'$name'} = \&sigcat; I get a like result it does not work as desired and a complete lack of quotes gives me a segmentation fault. On Fri, 2006-01-06 at 15:37 -0700, Wiggins d'Anconia wrote: > Leif Ericksen wrote: > > 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; > > In the above line you are single quoting $name so that it is not > interpolated. > > HTH, > > http://danconia.org > > > $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"; > > Might want to examine the output more closely, $name should be being > printed as $name rather than INT, HUP, etc. > > > 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>