sgt_b2002 has asked for the wisdom of the Perl Monks concerning the following question:
Hi everyone,
I'm using Term::ReadLine::Gnu and have run into a problem with signal handling. Given the script below and a TERM signal sent to the script, the handler for the TERM signal is not triggered until after the enter key is pressed. Using Term::ReadLine:Perl this does not occur.
I've read that Term::ReadLine::Gnu has its own internal signal handlers, but frankly I'm at a loss as to how to work with them.
I've reviewed the Gnu_Variables and tried setting the rl_catch_signals variable to 0, but that didn't help. Ideally, I'd like to work with the Gnu signal handlers, but I'll settle for disabling them too.
To be absolutely specific, I need the TERM handler to trigger after the signal is received instead of waiting for the enter key to be pressed.
Any help or advice is very much appreciated!
#!/usr/bin/perl use strict; use warnings; use Term::ReadLine; $SIG{TERM} = sub { print "I got a TERM\n"; exit; }; my $term = Term::ReadLine->new('Term1'); $term->ornaments(0); my $prompt = 'cmd> '; while ( defined (my $cmd = $term->readline($prompt)) ) { chomp($cmd); if ($cmd =~ /^help$/) { print "Help Menu\n"; } else { print "Nothing\n"; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Perl Term::ReadLine::Gnu Signal Handling Difficulties
by Mr. Muskrat (Canon) on Nov 13, 2012 at 06:00 UTC | |
by sgt_b2002 (Initiate) on Nov 13, 2012 at 13:50 UTC | |
by Mr. Muskrat (Canon) on Nov 13, 2012 at 14:07 UTC | |
by sgt_b2002 (Initiate) on Nov 13, 2012 at 14:35 UTC | |
by Mr. Muskrat (Canon) on Nov 13, 2012 at 14:45 UTC | |
|
Re: Perl Term::ReadLine::Gnu Signal Handling Difficulties
by Mr. Muskrat (Canon) on Nov 13, 2012 at 20:32 UTC | |
by sgt_b2002 (Initiate) on Nov 13, 2012 at 21:27 UTC | |
by Mr. Muskrat (Canon) on Nov 14, 2012 at 01:01 UTC |