From 299a61417a151b73fd82d1197f44780a6084cb80 Mon Sep 17 00:00:00 2001 From: Daniel Nichter Date: Sat, 10 Aug 2013 19:09:31 -0700 Subject: [PATCH] Use get_cmd_pid() again to avoid race condition. --- t/lib/Daemon.t | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/t/lib/Daemon.t b/t/lib/Daemon.t index 15a8eb0a..a1f04315 100644 --- a/t/lib/Daemon.t +++ b/t/lib/Daemon.t @@ -184,12 +184,13 @@ SKIP: { # pid-file is still running # ########################################################################## rm_tmp_files(); -system("$cmd 5 --daemonize --pid $pid_file >/dev/null 2>&1"); +system("$cmd 7 --daemonize --pid $pid_file >/dev/null 2>&1"); PerconaTest::wait_for_files($pid_file); -chomp($pid = slurp_file($pid_file)); +$pid = PerconaTest::get_cmd_pid("$cmd 7") + or die "Cannot get PID of $cmd 7"; kill 9, $pid; sleep 0.25; -(undef, $output) = PerconaTest::get_cmd_pid("$cmd 5"); +(undef, $output) = PerconaTest::get_cmd_pid("$cmd 7"); unlike( $output, qr/daemonize/, @@ -202,10 +203,10 @@ ok( my (undef, $tempfile) = tempfile(); -system("$cmd 5 --daemonize --log $log_file --pid $pid_file > $tempfile 2>&1"); +system("$cmd 6 --daemonize --log $log_file --pid $pid_file > $tempfile 2>&1"); PerconaTest::wait_for_files($log_file, $pid_file, $tempfile); my $new_pid; -($new_pid, $output) = PerconaTest::get_cmd_pid("$cmd 5"); +($new_pid, $output) = PerconaTest::get_cmd_pid("$cmd 6"); like( $output, @@ -219,8 +220,10 @@ like( 'Says that old PID is not running (issue 419)' ); -ok( - $pid != $new_pid, +cmp_ok( + $pid, + '!=', + $new_pid, 'Overwrites PID file with new PID (issue 419)' );