mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-06 04:17:55 +00:00
ReadKeyMini: Restore STDIN flags in cooked()
This will probably resolve bug #946707: pt-sift loses STDIN after pt-diskstats
This commit is contained in:
@@ -1322,6 +1322,7 @@ use English qw(-no_match_vars);
|
||||
use constant MKDEBUG => $ENV{MKDEBUG} || 0;
|
||||
|
||||
use POSIX qw( :termios_h );
|
||||
use Fcntl qw( F_SETFL F_GETFL );
|
||||
|
||||
use base qw( Exporter );
|
||||
|
||||
@@ -1344,8 +1345,12 @@ my %modes = (
|
||||
# This primarily comes from the Perl Cookbook, recipe 15.8
|
||||
|
||||
{
|
||||
|
||||
my $fd_stdin = fileno(STDIN);
|
||||
my $flags;
|
||||
unless ( $PerconaTest::DONT_RESTORE_STDIN ) {
|
||||
$flags = fcntl(STDIN, F_GETFL, 0)
|
||||
or die "can't fcntl F_GETFL: $!";
|
||||
}
|
||||
my $term = POSIX::Termios->new();
|
||||
$term->getattr($fd_stdin);
|
||||
my $oterm = $term->getlflag();
|
||||
@@ -1376,6 +1381,10 @@ my %modes = (
|
||||
$term->setlflag($oterm);
|
||||
$term->setcc( VTIME, 0 );
|
||||
$term->setattr( $fd_stdin, TCSANOW );
|
||||
unless ( $PerconaTest::DONT_RESTORE_STDIN ) {
|
||||
fcntl(STDIN, F_SETFL, $flags)
|
||||
or die "can't fcntl F_SETFL: $!";
|
||||
}
|
||||
}
|
||||
|
||||
END { cooked() }
|
||||
@@ -3407,7 +3416,7 @@ use English qw(-no_match_vars);
|
||||
use constant PTDEBUG => $ENV{PTDEBUG} || 0;
|
||||
|
||||
sub main {
|
||||
@ARGV = @_; # set global ARGV for this package
|
||||
local @ARGV = @_; # set global ARGV for this package
|
||||
|
||||
# ########################################################################
|
||||
# Get configuration information.
|
||||
|
Reference in New Issue
Block a user