mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-10 05:00:45 +00:00
Bug #995896: Useless use of cat in Daemon.pm
This commit is contained in:
@@ -125,7 +125,7 @@ sub check_PID_file {
|
|||||||
PTDEBUG && _d('Checking PID file', $PID_file);
|
PTDEBUG && _d('Checking PID file', $PID_file);
|
||||||
if ( $PID_file && -f $PID_file ) {
|
if ( $PID_file && -f $PID_file ) {
|
||||||
my $pid;
|
my $pid;
|
||||||
eval { chomp($pid = `cat $PID_file`); };
|
eval { chomp($pid = slurp_file($PID_file)); };
|
||||||
die "Cannot cat $PID_file: $OS_ERROR" if $EVAL_ERROR;
|
die "Cannot cat $PID_file: $OS_ERROR" if $EVAL_ERROR;
|
||||||
PTDEBUG && _d('PID file exists; it contains PID', $pid);
|
PTDEBUG && _d('PID file exists; it contains PID', $pid);
|
||||||
if ( $pid ) {
|
if ( $pid ) {
|
||||||
@@ -221,6 +221,12 @@ sub DESTROY {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub slurp_file {
|
||||||
|
my ($file) = @_;
|
||||||
|
open my $fh, "<", $file or die "Couldn't slurp file: $!";
|
||||||
|
return do { local $/; <$fh> };
|
||||||
|
}
|
||||||
|
|
||||||
sub _d {
|
sub _d {
|
||||||
my ($package, undef, $line) = caller 0;
|
my ($package, undef, $line) = caller 0;
|
||||||
@_ = map { (my $temp = $_) =~ s/\n/\n# /g; $temp; }
|
@_ = map { (my $temp = $_) =~ s/\n/\n# /g; $temp; }
|
||||||
|
Reference in New Issue
Block a user