mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-26 15:31: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:
@@ -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() }
|
||||
|
Reference in New Issue
Block a user