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:
Sveta Smirnova
2024-03-22 23:27:19 +03:00
parent d5eba438ef
commit d68f56c924
21 changed files with 299 additions and 2 deletions

View File

@@ -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 ) {