mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-02 02:34:19 +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.
|
||||
|
@@ -40,6 +40,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 );
|
||||
|
||||
@@ -68,6 +69,11 @@ my %modes = (
|
||||
{
|
||||
|
||||
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();
|
||||
@@ -98,6 +104,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() }
|
||||
|
@@ -92,6 +92,8 @@ sub test_diskstats_file {
|
||||
no_diff(
|
||||
sub {
|
||||
tie local *STDIN, TestInteractive => @commands;
|
||||
local $PerconaTest::DONT_RESTORE_STDIN =
|
||||
$PerconaTest::DONT_RESTORE_STDIN = 1;
|
||||
pt_diskstats::main(
|
||||
@options,
|
||||
'--group-by', $groupby,
|
||||
|
Reference in New Issue
Block a user