mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-01 18:25:59 +00:00
PT-2284 - pt-kill 3.5.5: "Wide character in printf at /usr/bin/pt-kill line 7553."
- Set binmode to utf8 for the Daemon log files - Added test case - Run update-modules
This commit is contained in:
@@ -3394,6 +3394,7 @@ sub new {
|
||||
force_log_file => $args{force_log_file},
|
||||
parent_exit => $args{parent_exit},
|
||||
pid_file_owner => 0,
|
||||
utf8 => $args{utf8} // 0,
|
||||
};
|
||||
return bless $self, $class;
|
||||
}
|
||||
@@ -3406,6 +3407,7 @@ sub run {
|
||||
my $log_file = $self->{log_file};
|
||||
my $force_log_file = $self->{force_log_file};
|
||||
my $parent_exit = $self->{parent_exit};
|
||||
my $utf8 = $self->{utf8};
|
||||
|
||||
PTDEBUG && _d('Starting daemon');
|
||||
|
||||
@@ -3452,10 +3454,19 @@ sub run {
|
||||
close STDOUT;
|
||||
open STDOUT, '>>', $log_file
|
||||
or die "Cannot open log file $log_file: $OS_ERROR";
|
||||
if ( $utf8 ) {
|
||||
binmode(STDOUT, ':utf8')
|
||||
or die "Can't binmode(STDOUT, ':utf8'): $OS_ERROR";
|
||||
}
|
||||
|
||||
|
||||
close STDERR;
|
||||
open STDERR, ">&STDOUT"
|
||||
or die "Cannot dupe STDERR to STDOUT: $OS_ERROR";
|
||||
if ( $utf8 ) {
|
||||
binmode(STDERR, ':utf8')
|
||||
or die "Can't binmode(STDERR, ':utf8'): $OS_ERROR";
|
||||
}
|
||||
}
|
||||
else {
|
||||
if ( -t STDOUT ) {
|
||||
|
@@ -2607,6 +2607,7 @@ sub new {
|
||||
force_log_file => $args{force_log_file},
|
||||
parent_exit => $args{parent_exit},
|
||||
pid_file_owner => 0,
|
||||
utf8 => $args{utf8} // 0,
|
||||
};
|
||||
return bless $self, $class;
|
||||
}
|
||||
@@ -2619,6 +2620,7 @@ sub run {
|
||||
my $log_file = $self->{log_file};
|
||||
my $force_log_file = $self->{force_log_file};
|
||||
my $parent_exit = $self->{parent_exit};
|
||||
my $utf8 = $self->{utf8};
|
||||
|
||||
PTDEBUG && _d('Starting daemon');
|
||||
|
||||
@@ -2665,10 +2667,19 @@ sub run {
|
||||
close STDOUT;
|
||||
open STDOUT, '>>', $log_file
|
||||
or die "Cannot open log file $log_file: $OS_ERROR";
|
||||
if ( $utf8 ) {
|
||||
binmode(STDOUT, ':utf8')
|
||||
or die "Can't binmode(STDOUT, ':utf8'): $OS_ERROR";
|
||||
}
|
||||
|
||||
|
||||
close STDERR;
|
||||
open STDERR, ">&STDOUT"
|
||||
or die "Cannot dupe STDERR to STDOUT: $OS_ERROR";
|
||||
if ( $utf8 ) {
|
||||
binmode(STDERR, ':utf8')
|
||||
or die "Can't binmode(STDERR, ':utf8'): $OS_ERROR";
|
||||
}
|
||||
}
|
||||
else {
|
||||
if ( -t STDOUT ) {
|
||||
|
@@ -2951,6 +2951,7 @@ sub new {
|
||||
force_log_file => $args{force_log_file},
|
||||
parent_exit => $args{parent_exit},
|
||||
pid_file_owner => 0,
|
||||
utf8 => $args{utf8} // 0,
|
||||
};
|
||||
return bless $self, $class;
|
||||
}
|
||||
@@ -2963,6 +2964,7 @@ sub run {
|
||||
my $log_file = $self->{log_file};
|
||||
my $force_log_file = $self->{force_log_file};
|
||||
my $parent_exit = $self->{parent_exit};
|
||||
my $utf8 = $self->{utf8};
|
||||
|
||||
PTDEBUG && _d('Starting daemon');
|
||||
|
||||
@@ -3009,10 +3011,19 @@ sub run {
|
||||
close STDOUT;
|
||||
open STDOUT, '>>', $log_file
|
||||
or die "Cannot open log file $log_file: $OS_ERROR";
|
||||
if ( $utf8 ) {
|
||||
binmode(STDOUT, ':utf8')
|
||||
or die "Can't binmode(STDOUT, ':utf8'): $OS_ERROR";
|
||||
}
|
||||
|
||||
|
||||
close STDERR;
|
||||
open STDERR, ">&STDOUT"
|
||||
or die "Cannot dupe STDERR to STDOUT: $OS_ERROR";
|
||||
if ( $utf8 ) {
|
||||
binmode(STDERR, ':utf8')
|
||||
or die "Can't binmode(STDERR, ':utf8'): $OS_ERROR";
|
||||
}
|
||||
}
|
||||
else {
|
||||
if ( -t STDOUT ) {
|
||||
|
@@ -2835,6 +2835,7 @@ sub new {
|
||||
force_log_file => $args{force_log_file},
|
||||
parent_exit => $args{parent_exit},
|
||||
pid_file_owner => 0,
|
||||
utf8 => $args{utf8} // 0,
|
||||
};
|
||||
return bless $self, $class;
|
||||
}
|
||||
@@ -2847,6 +2848,7 @@ sub run {
|
||||
my $log_file = $self->{log_file};
|
||||
my $force_log_file = $self->{force_log_file};
|
||||
my $parent_exit = $self->{parent_exit};
|
||||
my $utf8 = $self->{utf8};
|
||||
|
||||
PTDEBUG && _d('Starting daemon');
|
||||
|
||||
@@ -2893,10 +2895,19 @@ sub run {
|
||||
close STDOUT;
|
||||
open STDOUT, '>>', $log_file
|
||||
or die "Cannot open log file $log_file: $OS_ERROR";
|
||||
if ( $utf8 ) {
|
||||
binmode(STDOUT, ':utf8')
|
||||
or die "Can't binmode(STDOUT, ':utf8'): $OS_ERROR";
|
||||
}
|
||||
|
||||
|
||||
close STDERR;
|
||||
open STDERR, ">&STDOUT"
|
||||
or die "Cannot dupe STDERR to STDOUT: $OS_ERROR";
|
||||
if ( $utf8 ) {
|
||||
binmode(STDERR, ':utf8')
|
||||
or die "Can't binmode(STDERR, ':utf8'): $OS_ERROR";
|
||||
}
|
||||
}
|
||||
else {
|
||||
if ( -t STDOUT ) {
|
||||
|
@@ -1158,6 +1158,7 @@ sub new {
|
||||
force_log_file => $args{force_log_file},
|
||||
parent_exit => $args{parent_exit},
|
||||
pid_file_owner => 0,
|
||||
utf8 => $args{utf8} // 0,
|
||||
};
|
||||
return bless $self, $class;
|
||||
}
|
||||
@@ -1170,6 +1171,7 @@ sub run {
|
||||
my $log_file = $self->{log_file};
|
||||
my $force_log_file = $self->{force_log_file};
|
||||
my $parent_exit = $self->{parent_exit};
|
||||
my $utf8 = $self->{utf8};
|
||||
|
||||
PTDEBUG && _d('Starting daemon');
|
||||
|
||||
@@ -1216,10 +1218,19 @@ sub run {
|
||||
close STDOUT;
|
||||
open STDOUT, '>>', $log_file
|
||||
or die "Cannot open log file $log_file: $OS_ERROR";
|
||||
if ( $utf8 ) {
|
||||
binmode(STDOUT, ':utf8')
|
||||
or die "Can't binmode(STDOUT, ':utf8'): $OS_ERROR";
|
||||
}
|
||||
|
||||
|
||||
close STDERR;
|
||||
open STDERR, ">&STDOUT"
|
||||
or die "Cannot dupe STDERR to STDOUT: $OS_ERROR";
|
||||
if ( $utf8 ) {
|
||||
binmode(STDERR, ':utf8')
|
||||
or die "Can't binmode(STDERR, ':utf8'): $OS_ERROR";
|
||||
}
|
||||
}
|
||||
else {
|
||||
if ( -t STDOUT ) {
|
||||
|
11
bin/pt-find
11
bin/pt-find
@@ -2277,6 +2277,7 @@ sub new {
|
||||
force_log_file => $args{force_log_file},
|
||||
parent_exit => $args{parent_exit},
|
||||
pid_file_owner => 0,
|
||||
utf8 => $args{utf8} // 0,
|
||||
};
|
||||
return bless $self, $class;
|
||||
}
|
||||
@@ -2289,6 +2290,7 @@ sub run {
|
||||
my $log_file = $self->{log_file};
|
||||
my $force_log_file = $self->{force_log_file};
|
||||
my $parent_exit = $self->{parent_exit};
|
||||
my $utf8 = $self->{utf8};
|
||||
|
||||
PTDEBUG && _d('Starting daemon');
|
||||
|
||||
@@ -2335,10 +2337,19 @@ sub run {
|
||||
close STDOUT;
|
||||
open STDOUT, '>>', $log_file
|
||||
or die "Cannot open log file $log_file: $OS_ERROR";
|
||||
if ( $utf8 ) {
|
||||
binmode(STDOUT, ':utf8')
|
||||
or die "Can't binmode(STDOUT, ':utf8'): $OS_ERROR";
|
||||
}
|
||||
|
||||
|
||||
close STDERR;
|
||||
open STDERR, ">&STDOUT"
|
||||
or die "Cannot dupe STDERR to STDOUT: $OS_ERROR";
|
||||
if ( $utf8 ) {
|
||||
binmode(STDERR, ':utf8')
|
||||
or die "Can't binmode(STDERR, ':utf8'): $OS_ERROR";
|
||||
}
|
||||
}
|
||||
else {
|
||||
if ( -t STDOUT ) {
|
||||
|
@@ -2105,6 +2105,7 @@ sub new {
|
||||
force_log_file => $args{force_log_file},
|
||||
parent_exit => $args{parent_exit},
|
||||
pid_file_owner => 0,
|
||||
utf8 => $args{utf8} // 0,
|
||||
};
|
||||
return bless $self, $class;
|
||||
}
|
||||
@@ -2117,6 +2118,7 @@ sub run {
|
||||
my $log_file = $self->{log_file};
|
||||
my $force_log_file = $self->{force_log_file};
|
||||
my $parent_exit = $self->{parent_exit};
|
||||
my $utf8 = $self->{utf8};
|
||||
|
||||
PTDEBUG && _d('Starting daemon');
|
||||
|
||||
@@ -2163,10 +2165,19 @@ sub run {
|
||||
close STDOUT;
|
||||
open STDOUT, '>>', $log_file
|
||||
or die "Cannot open log file $log_file: $OS_ERROR";
|
||||
if ( $utf8 ) {
|
||||
binmode(STDOUT, ':utf8')
|
||||
or die "Can't binmode(STDOUT, ':utf8'): $OS_ERROR";
|
||||
}
|
||||
|
||||
|
||||
close STDERR;
|
||||
open STDERR, ">&STDOUT"
|
||||
or die "Cannot dupe STDERR to STDOUT: $OS_ERROR";
|
||||
if ( $utf8 ) {
|
||||
binmode(STDERR, ':utf8')
|
||||
or die "Can't binmode(STDERR, ':utf8'): $OS_ERROR";
|
||||
}
|
||||
}
|
||||
else {
|
||||
if ( -t STDOUT ) {
|
||||
|
@@ -3208,6 +3208,7 @@ sub new {
|
||||
force_log_file => $args{force_log_file},
|
||||
parent_exit => $args{parent_exit},
|
||||
pid_file_owner => 0,
|
||||
utf8 => $args{utf8} // 0,
|
||||
};
|
||||
return bless $self, $class;
|
||||
}
|
||||
@@ -3220,6 +3221,7 @@ sub run {
|
||||
my $log_file = $self->{log_file};
|
||||
my $force_log_file = $self->{force_log_file};
|
||||
my $parent_exit = $self->{parent_exit};
|
||||
my $utf8 = $self->{utf8};
|
||||
|
||||
PTDEBUG && _d('Starting daemon');
|
||||
|
||||
@@ -3266,10 +3268,19 @@ sub run {
|
||||
close STDOUT;
|
||||
open STDOUT, '>>', $log_file
|
||||
or die "Cannot open log file $log_file: $OS_ERROR";
|
||||
if ( $utf8 ) {
|
||||
binmode(STDOUT, ':utf8')
|
||||
or die "Can't binmode(STDOUT, ':utf8'): $OS_ERROR";
|
||||
}
|
||||
|
||||
|
||||
close STDERR;
|
||||
open STDERR, ">&STDOUT"
|
||||
or die "Cannot dupe STDERR to STDOUT: $OS_ERROR";
|
||||
if ( $utf8 ) {
|
||||
binmode(STDERR, ':utf8')
|
||||
or die "Can't binmode(STDERR, ':utf8'): $OS_ERROR";
|
||||
}
|
||||
}
|
||||
else {
|
||||
if ( -t STDOUT ) {
|
||||
|
20
bin/pt-kill
20
bin/pt-kill
@@ -2333,6 +2333,7 @@ sub new {
|
||||
force_log_file => $args{force_log_file},
|
||||
parent_exit => $args{parent_exit},
|
||||
pid_file_owner => 0,
|
||||
utf8 => $args{utf8} // 0,
|
||||
};
|
||||
return bless $self, $class;
|
||||
}
|
||||
@@ -2345,6 +2346,7 @@ sub run {
|
||||
my $log_file = $self->{log_file};
|
||||
my $force_log_file = $self->{force_log_file};
|
||||
my $parent_exit = $self->{parent_exit};
|
||||
my $utf8 = $self->{utf8};
|
||||
|
||||
PTDEBUG && _d('Starting daemon');
|
||||
|
||||
@@ -2391,10 +2393,19 @@ sub run {
|
||||
close STDOUT;
|
||||
open STDOUT, '>>', $log_file
|
||||
or die "Cannot open log file $log_file: $OS_ERROR";
|
||||
if ( $utf8 ) {
|
||||
binmode(STDOUT, ':utf8')
|
||||
or die "Can't binmode(STDOUT, ':utf8'): $OS_ERROR";
|
||||
}
|
||||
|
||||
|
||||
close STDERR;
|
||||
open STDERR, ">&STDOUT"
|
||||
or die "Cannot dupe STDERR to STDOUT: $OS_ERROR";
|
||||
if ( $utf8 ) {
|
||||
binmode(STDERR, ':utf8')
|
||||
or die "Can't binmode(STDERR, ':utf8'): $OS_ERROR";
|
||||
}
|
||||
}
|
||||
else {
|
||||
if ( -t STDOUT ) {
|
||||
@@ -7340,11 +7351,16 @@ sub main {
|
||||
# we're not daemoninzing, it just handles PID stuff.
|
||||
# ########################################################################
|
||||
my $daemon;
|
||||
my $utf8 = 0;
|
||||
if ( $dbh && $dbh->{mysql_enable_utf8} ) {
|
||||
$utf8 = 1;
|
||||
}
|
||||
if ( $o->get('daemonize') || $o->get('pid')) {
|
||||
$daemon = new Daemon(
|
||||
log_file => $o->get('log'),
|
||||
pid_file => $o->get('pid'),
|
||||
log_file => $o->get('log'),
|
||||
pid_file => $o->get('pid'),
|
||||
daemonize => $o->get('daemonize'),
|
||||
utf8 => $utf8,
|
||||
);
|
||||
$daemon->run();
|
||||
PTDEBUG && $o->get('daemonize') && _d('I am a daemon now');
|
||||
|
@@ -2583,6 +2583,7 @@ sub new {
|
||||
force_log_file => $args{force_log_file},
|
||||
parent_exit => $args{parent_exit},
|
||||
pid_file_owner => 0,
|
||||
utf8 => $args{utf8} // 0,
|
||||
};
|
||||
return bless $self, $class;
|
||||
}
|
||||
@@ -2595,6 +2596,7 @@ sub run {
|
||||
my $log_file = $self->{log_file};
|
||||
my $force_log_file = $self->{force_log_file};
|
||||
my $parent_exit = $self->{parent_exit};
|
||||
my $utf8 = $self->{utf8};
|
||||
|
||||
PTDEBUG && _d('Starting daemon');
|
||||
|
||||
@@ -2641,10 +2643,19 @@ sub run {
|
||||
close STDOUT;
|
||||
open STDOUT, '>>', $log_file
|
||||
or die "Cannot open log file $log_file: $OS_ERROR";
|
||||
if ( $utf8 ) {
|
||||
binmode(STDOUT, ':utf8')
|
||||
or die "Can't binmode(STDOUT, ':utf8'): $OS_ERROR";
|
||||
}
|
||||
|
||||
|
||||
close STDERR;
|
||||
open STDERR, ">&STDOUT"
|
||||
or die "Cannot dupe STDERR to STDOUT: $OS_ERROR";
|
||||
if ( $utf8 ) {
|
||||
binmode(STDERR, ':utf8')
|
||||
or die "Can't binmode(STDERR, ':utf8'): $OS_ERROR";
|
||||
}
|
||||
}
|
||||
else {
|
||||
if ( -t STDOUT ) {
|
||||
|
@@ -9508,6 +9508,7 @@ sub new {
|
||||
force_log_file => $args{force_log_file},
|
||||
parent_exit => $args{parent_exit},
|
||||
pid_file_owner => 0,
|
||||
utf8 => $args{utf8} // 0,
|
||||
};
|
||||
return bless $self, $class;
|
||||
}
|
||||
@@ -9520,6 +9521,7 @@ sub run {
|
||||
my $log_file = $self->{log_file};
|
||||
my $force_log_file = $self->{force_log_file};
|
||||
my $parent_exit = $self->{parent_exit};
|
||||
my $utf8 = $self->{utf8};
|
||||
|
||||
PTDEBUG && _d('Starting daemon');
|
||||
|
||||
@@ -9566,10 +9568,19 @@ sub run {
|
||||
close STDOUT;
|
||||
open STDOUT, '>>', $log_file
|
||||
or die "Cannot open log file $log_file: $OS_ERROR";
|
||||
if ( $utf8 ) {
|
||||
binmode(STDOUT, ':utf8')
|
||||
or die "Can't binmode(STDOUT, ':utf8'): $OS_ERROR";
|
||||
}
|
||||
|
||||
|
||||
close STDERR;
|
||||
open STDERR, ">&STDOUT"
|
||||
or die "Cannot dupe STDERR to STDOUT: $OS_ERROR";
|
||||
if ( $utf8 ) {
|
||||
binmode(STDERR, ':utf8')
|
||||
or die "Can't binmode(STDERR, ':utf8'): $OS_ERROR";
|
||||
}
|
||||
}
|
||||
else {
|
||||
if ( -t STDOUT ) {
|
||||
|
@@ -1605,6 +1605,7 @@ sub new {
|
||||
force_log_file => $args{force_log_file},
|
||||
parent_exit => $args{parent_exit},
|
||||
pid_file_owner => 0,
|
||||
utf8 => $args{utf8} // 0,
|
||||
};
|
||||
return bless $self, $class;
|
||||
}
|
||||
@@ -1617,6 +1618,7 @@ sub run {
|
||||
my $log_file = $self->{log_file};
|
||||
my $force_log_file = $self->{force_log_file};
|
||||
my $parent_exit = $self->{parent_exit};
|
||||
my $utf8 = $self->{utf8};
|
||||
|
||||
PTDEBUG && _d('Starting daemon');
|
||||
|
||||
@@ -1663,10 +1665,19 @@ sub run {
|
||||
close STDOUT;
|
||||
open STDOUT, '>>', $log_file
|
||||
or die "Cannot open log file $log_file: $OS_ERROR";
|
||||
if ( $utf8 ) {
|
||||
binmode(STDOUT, ':utf8')
|
||||
or die "Can't binmode(STDOUT, ':utf8'): $OS_ERROR";
|
||||
}
|
||||
|
||||
|
||||
close STDERR;
|
||||
open STDERR, ">&STDOUT"
|
||||
or die "Cannot dupe STDERR to STDOUT: $OS_ERROR";
|
||||
if ( $utf8 ) {
|
||||
binmode(STDERR, ':utf8')
|
||||
or die "Can't binmode(STDERR, ':utf8'): $OS_ERROR";
|
||||
}
|
||||
}
|
||||
else {
|
||||
if ( -t STDOUT ) {
|
||||
|
@@ -2326,6 +2326,7 @@ sub new {
|
||||
force_log_file => $args{force_log_file},
|
||||
parent_exit => $args{parent_exit},
|
||||
pid_file_owner => 0,
|
||||
utf8 => $args{utf8} // 0,
|
||||
};
|
||||
return bless $self, $class;
|
||||
}
|
||||
@@ -2338,6 +2339,7 @@ sub run {
|
||||
my $log_file = $self->{log_file};
|
||||
my $force_log_file = $self->{force_log_file};
|
||||
my $parent_exit = $self->{parent_exit};
|
||||
my $utf8 = $self->{utf8};
|
||||
|
||||
PTDEBUG && _d('Starting daemon');
|
||||
|
||||
@@ -2384,10 +2386,19 @@ sub run {
|
||||
close STDOUT;
|
||||
open STDOUT, '>>', $log_file
|
||||
or die "Cannot open log file $log_file: $OS_ERROR";
|
||||
if ( $utf8 ) {
|
||||
binmode(STDOUT, ':utf8')
|
||||
or die "Can't binmode(STDOUT, ':utf8'): $OS_ERROR";
|
||||
}
|
||||
|
||||
|
||||
close STDERR;
|
||||
open STDERR, ">&STDOUT"
|
||||
or die "Cannot dupe STDERR to STDOUT: $OS_ERROR";
|
||||
if ( $utf8 ) {
|
||||
binmode(STDERR, ':utf8')
|
||||
or die "Can't binmode(STDERR, ':utf8'): $OS_ERROR";
|
||||
}
|
||||
}
|
||||
else {
|
||||
if ( -t STDOUT ) {
|
||||
|
@@ -3139,6 +3139,7 @@ sub new {
|
||||
force_log_file => $args{force_log_file},
|
||||
parent_exit => $args{parent_exit},
|
||||
pid_file_owner => 0,
|
||||
utf8 => $args{utf8} // 0,
|
||||
};
|
||||
return bless $self, $class;
|
||||
}
|
||||
@@ -3151,6 +3152,7 @@ sub run {
|
||||
my $log_file = $self->{log_file};
|
||||
my $force_log_file = $self->{force_log_file};
|
||||
my $parent_exit = $self->{parent_exit};
|
||||
my $utf8 = $self->{utf8};
|
||||
|
||||
PTDEBUG && _d('Starting daemon');
|
||||
|
||||
@@ -3197,10 +3199,19 @@ sub run {
|
||||
close STDOUT;
|
||||
open STDOUT, '>>', $log_file
|
||||
or die "Cannot open log file $log_file: $OS_ERROR";
|
||||
if ( $utf8 ) {
|
||||
binmode(STDOUT, ':utf8')
|
||||
or die "Can't binmode(STDOUT, ':utf8'): $OS_ERROR";
|
||||
}
|
||||
|
||||
|
||||
close STDERR;
|
||||
open STDERR, ">&STDOUT"
|
||||
or die "Cannot dupe STDERR to STDOUT: $OS_ERROR";
|
||||
if ( $utf8 ) {
|
||||
binmode(STDERR, ':utf8')
|
||||
or die "Can't binmode(STDERR, ':utf8'): $OS_ERROR";
|
||||
}
|
||||
}
|
||||
else {
|
||||
if ( -t STDOUT ) {
|
||||
|
@@ -3550,6 +3550,7 @@ sub new {
|
||||
force_log_file => $args{force_log_file},
|
||||
parent_exit => $args{parent_exit},
|
||||
pid_file_owner => 0,
|
||||
utf8 => $args{utf8} // 0,
|
||||
};
|
||||
return bless $self, $class;
|
||||
}
|
||||
@@ -3562,6 +3563,7 @@ sub run {
|
||||
my $log_file = $self->{log_file};
|
||||
my $force_log_file = $self->{force_log_file};
|
||||
my $parent_exit = $self->{parent_exit};
|
||||
my $utf8 = $self->{utf8};
|
||||
|
||||
PTDEBUG && _d('Starting daemon');
|
||||
|
||||
@@ -3608,10 +3610,19 @@ sub run {
|
||||
close STDOUT;
|
||||
open STDOUT, '>>', $log_file
|
||||
or die "Cannot open log file $log_file: $OS_ERROR";
|
||||
if ( $utf8 ) {
|
||||
binmode(STDOUT, ':utf8')
|
||||
or die "Can't binmode(STDOUT, ':utf8'): $OS_ERROR";
|
||||
}
|
||||
|
||||
|
||||
close STDERR;
|
||||
open STDERR, ">&STDOUT"
|
||||
or die "Cannot dupe STDERR to STDOUT: $OS_ERROR";
|
||||
if ( $utf8 ) {
|
||||
binmode(STDERR, ':utf8')
|
||||
or die "Can't binmode(STDERR, ':utf8'): $OS_ERROR";
|
||||
}
|
||||
}
|
||||
else {
|
||||
if ( -t STDOUT ) {
|
||||
|
@@ -7450,6 +7450,7 @@ sub new {
|
||||
force_log_file => $args{force_log_file},
|
||||
parent_exit => $args{parent_exit},
|
||||
pid_file_owner => 0,
|
||||
utf8 => $args{utf8} // 0,
|
||||
};
|
||||
return bless $self, $class;
|
||||
}
|
||||
@@ -7462,6 +7463,7 @@ sub run {
|
||||
my $log_file = $self->{log_file};
|
||||
my $force_log_file = $self->{force_log_file};
|
||||
my $parent_exit = $self->{parent_exit};
|
||||
my $utf8 = $self->{utf8};
|
||||
|
||||
PTDEBUG && _d('Starting daemon');
|
||||
|
||||
@@ -7508,10 +7510,19 @@ sub run {
|
||||
close STDOUT;
|
||||
open STDOUT, '>>', $log_file
|
||||
or die "Cannot open log file $log_file: $OS_ERROR";
|
||||
if ( $utf8 ) {
|
||||
binmode(STDOUT, ':utf8')
|
||||
or die "Can't binmode(STDOUT, ':utf8'): $OS_ERROR";
|
||||
}
|
||||
|
||||
|
||||
close STDERR;
|
||||
open STDERR, ">&STDOUT"
|
||||
or die "Cannot dupe STDERR to STDOUT: $OS_ERROR";
|
||||
if ( $utf8 ) {
|
||||
binmode(STDERR, ':utf8')
|
||||
or die "Can't binmode(STDERR, ':utf8'): $OS_ERROR";
|
||||
}
|
||||
}
|
||||
else {
|
||||
if ( -t STDOUT ) {
|
||||
|
@@ -7568,6 +7568,7 @@ sub new {
|
||||
force_log_file => $args{force_log_file},
|
||||
parent_exit => $args{parent_exit},
|
||||
pid_file_owner => 0,
|
||||
utf8 => $args{utf8} // 0,
|
||||
};
|
||||
return bless $self, $class;
|
||||
}
|
||||
@@ -7580,6 +7581,7 @@ sub run {
|
||||
my $log_file = $self->{log_file};
|
||||
my $force_log_file = $self->{force_log_file};
|
||||
my $parent_exit = $self->{parent_exit};
|
||||
my $utf8 = $self->{utf8};
|
||||
|
||||
PTDEBUG && _d('Starting daemon');
|
||||
|
||||
@@ -7626,10 +7628,19 @@ sub run {
|
||||
close STDOUT;
|
||||
open STDOUT, '>>', $log_file
|
||||
or die "Cannot open log file $log_file: $OS_ERROR";
|
||||
if ( $utf8 ) {
|
||||
binmode(STDOUT, ':utf8')
|
||||
or die "Can't binmode(STDOUT, ':utf8'): $OS_ERROR";
|
||||
}
|
||||
|
||||
|
||||
close STDERR;
|
||||
open STDERR, ">&STDOUT"
|
||||
or die "Cannot dupe STDERR to STDOUT: $OS_ERROR";
|
||||
if ( $utf8 ) {
|
||||
binmode(STDERR, ':utf8')
|
||||
or die "Can't binmode(STDERR, ':utf8'): $OS_ERROR";
|
||||
}
|
||||
}
|
||||
else {
|
||||
if ( -t STDOUT ) {
|
||||
|
@@ -3131,6 +3131,7 @@ sub new {
|
||||
force_log_file => $args{force_log_file},
|
||||
parent_exit => $args{parent_exit},
|
||||
pid_file_owner => 0,
|
||||
utf8 => $args{utf8} // 0,
|
||||
};
|
||||
return bless $self, $class;
|
||||
}
|
||||
@@ -3143,6 +3144,7 @@ sub run {
|
||||
my $log_file = $self->{log_file};
|
||||
my $force_log_file = $self->{force_log_file};
|
||||
my $parent_exit = $self->{parent_exit};
|
||||
my $utf8 = $self->{utf8};
|
||||
|
||||
PTDEBUG && _d('Starting daemon');
|
||||
|
||||
@@ -3189,10 +3191,19 @@ sub run {
|
||||
close STDOUT;
|
||||
open STDOUT, '>>', $log_file
|
||||
or die "Cannot open log file $log_file: $OS_ERROR";
|
||||
if ( $utf8 ) {
|
||||
binmode(STDOUT, ':utf8')
|
||||
or die "Can't binmode(STDOUT, ':utf8'): $OS_ERROR";
|
||||
}
|
||||
|
||||
|
||||
close STDERR;
|
||||
open STDERR, ">&STDOUT"
|
||||
or die "Cannot dupe STDERR to STDOUT: $OS_ERROR";
|
||||
if ( $utf8 ) {
|
||||
binmode(STDERR, ':utf8')
|
||||
or die "Can't binmode(STDERR, ':utf8'): $OS_ERROR";
|
||||
}
|
||||
}
|
||||
else {
|
||||
if ( -t STDOUT ) {
|
||||
|
@@ -2522,6 +2522,7 @@ sub new {
|
||||
force_log_file => $args{force_log_file},
|
||||
parent_exit => $args{parent_exit},
|
||||
pid_file_owner => 0,
|
||||
utf8 => $args{utf8} // 0,
|
||||
};
|
||||
return bless $self, $class;
|
||||
}
|
||||
@@ -2534,6 +2535,7 @@ sub run {
|
||||
my $log_file = $self->{log_file};
|
||||
my $force_log_file = $self->{force_log_file};
|
||||
my $parent_exit = $self->{parent_exit};
|
||||
my $utf8 = $self->{utf8};
|
||||
|
||||
PTDEBUG && _d('Starting daemon');
|
||||
|
||||
@@ -2580,10 +2582,19 @@ sub run {
|
||||
close STDOUT;
|
||||
open STDOUT, '>>', $log_file
|
||||
or die "Cannot open log file $log_file: $OS_ERROR";
|
||||
if ( $utf8 ) {
|
||||
binmode(STDOUT, ':utf8')
|
||||
or die "Can't binmode(STDOUT, ':utf8'): $OS_ERROR";
|
||||
}
|
||||
|
||||
|
||||
close STDERR;
|
||||
open STDERR, ">&STDOUT"
|
||||
or die "Cannot dupe STDERR to STDOUT: $OS_ERROR";
|
||||
if ( $utf8 ) {
|
||||
binmode(STDERR, ':utf8')
|
||||
or die "Can't binmode(STDERR, ':utf8'): $OS_ERROR";
|
||||
}
|
||||
}
|
||||
else {
|
||||
if ( -t STDOUT ) {
|
||||
|
@@ -37,6 +37,7 @@ sub new {
|
||||
force_log_file => $args{force_log_file},
|
||||
parent_exit => $args{parent_exit},
|
||||
pid_file_owner => 0,
|
||||
utf8 => $args{utf8} // 0,
|
||||
};
|
||||
return bless $self, $class;
|
||||
}
|
||||
@@ -50,6 +51,7 @@ sub run {
|
||||
my $log_file = $self->{log_file};
|
||||
my $force_log_file = $self->{force_log_file};
|
||||
my $parent_exit = $self->{parent_exit};
|
||||
my $utf8 = $self->{utf8};
|
||||
|
||||
PTDEBUG && _d('Starting daemon');
|
||||
|
||||
@@ -116,6 +118,11 @@ sub run {
|
||||
close STDOUT;
|
||||
open STDOUT, '>>', $log_file
|
||||
or die "Cannot open log file $log_file: $OS_ERROR";
|
||||
if ( $utf8 ) {
|
||||
binmode(STDOUT, ':utf8')
|
||||
or die "Can't binmode(STDOUT, ':utf8'): $OS_ERROR";
|
||||
}
|
||||
|
||||
|
||||
# If we don't close STDERR explicitly, then prove Daemon.t fails
|
||||
# because STDERR gets written before STDOUT even though we print
|
||||
@@ -124,6 +131,10 @@ sub run {
|
||||
close STDERR;
|
||||
open STDERR, ">&STDOUT"
|
||||
or die "Cannot dupe STDERR to STDOUT: $OS_ERROR";
|
||||
if ( $utf8 ) {
|
||||
binmode(STDERR, ':utf8')
|
||||
or die "Can't binmode(STDERR, ':utf8'): $OS_ERROR";
|
||||
}
|
||||
}
|
||||
else {
|
||||
if ( -t STDOUT ) {
|
||||
|
72
t/pt-kill/pt-2284.t
Normal file
72
t/pt-kill/pt-2284.t
Normal file
@@ -0,0 +1,72 @@
|
||||
#!/usr/bin/env perl
|
||||
|
||||
BEGIN {
|
||||
die "The PERCONA_TOOLKIT_BRANCH environment variable is not set.\n"
|
||||
unless $ENV{PERCONA_TOOLKIT_BRANCH} && -d $ENV{PERCONA_TOOLKIT_BRANCH};
|
||||
unshift @INC, "$ENV{PERCONA_TOOLKIT_BRANCH}/lib";
|
||||
};
|
||||
|
||||
use strict;
|
||||
use warnings FATAL => 'all';
|
||||
use English qw(-no_match_vars);
|
||||
use Test::More tests => 6;
|
||||
|
||||
use PerconaTest;
|
||||
use Sandbox;
|
||||
require "$trunk/bin/pt-kill";
|
||||
|
||||
my $dp = new DSNParser(opts=>$dsn_opts);
|
||||
my $sb = new Sandbox(basedir => '/tmp', DSNParser => $dp);
|
||||
my $master_dbh = $sb->get_dbh_for('master');
|
||||
|
||||
my $output;
|
||||
my $cnf='/tmp/12345/my.sandbox.cnf';
|
||||
my $cmd = "$trunk/bin/pt-kill -F $cnf -h 127.1";
|
||||
|
||||
if ( !$master_dbh ) {
|
||||
plan skip_all => 'Cannot connect to sandbox master';
|
||||
}
|
||||
|
||||
`$cmd --print --interval 1s --run-time 20 --pid /tmp/pt-kill.pid --log /tmp/pt-kill.log --daemonize --busy-time 5 --kill-query --victims all --charset utf8mb4`;
|
||||
$output = `ps -eaf | grep 'pt-kill \-F'`;
|
||||
|
||||
ok(
|
||||
-f '/tmp/pt-kill.pid',
|
||||
'PID file created'
|
||||
);
|
||||
|
||||
ok(
|
||||
-f '/tmp/pt-kill.log',
|
||||
'Log file created'
|
||||
);
|
||||
|
||||
$master_dbh->do("select '柏木', sleep(20);");
|
||||
|
||||
wait_until(sub { return !-f '/tmp/pt-kill.pid' });
|
||||
ok(
|
||||
!-f '/tmp/pt-kill.pid',
|
||||
'PID file removed'
|
||||
);
|
||||
|
||||
$output = `cat /tmp/pt-kill.log`;
|
||||
|
||||
unlike(
|
||||
$output,
|
||||
qr/Wide character in printf/,
|
||||
'Error "Wide character in printf" not printed'
|
||||
) or diag($output);
|
||||
|
||||
like(
|
||||
$output,
|
||||
qr/柏木/,
|
||||
'Hieroglif printed'
|
||||
) or diag($output);
|
||||
|
||||
diag(`rm -rf /tmp/pt-kill.log 2>/dev/null`);
|
||||
|
||||
# #############################################################################
|
||||
# Done.
|
||||
# #############################################################################
|
||||
$sb->wipe_clean($master_dbh) if $master_dbh;
|
||||
ok($sb->ok(), "Sandbox servers") or BAIL_OUT(__FILE__ . " broke the sandbox");
|
||||
exit;
|
Reference in New Issue
Block a user