use B; use Term::ReadLine; $SIG{INT} = \&sigInt; $term = Term::ReadLine->new("sigfail"); while ($resp = $term->readline("test> ")) { if ($resp =~ m/^exit/) { last; } elsif ($resp =~ m/^loop/) { loop: goto loop; } elsif ($resp =~ m/^reload/) { reload() } elsif ($resp =~ m/sig/) { sig() } else { print "What?\n"; } } sub codeToName { my ($coderef) = @_; my $cv = B::svref_2object($coderef); return "" unless defined($cv) && defined($cv->GV); return $cv->GV->NAME; } sub reload { print "Reloading sigfail.pl\n"; exec("./sigfail.pl") } sub sigInt { print "Caught\n"; reload() } sub sig { map { print "$_: ",codeToName($SIG{$_}),"\n" if defined($SIG{$_}) && ref($SIG{$_}) eq "CODE" } sort { $a cmp $b } keys %SIG; }
In reply to Re^2: signals after exec
by tdlewis77
in thread signals after exec
by tdlewis77
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |