summaryrefslogtreecommitdiff
path: root/mysql-test/lib/mtr_io.pl
diff options
context:
space:
mode:
authorunknown <msvensson@shellback.(none)>2006-10-31 19:02:33 +0100
committerunknown <msvensson@shellback.(none)>2006-10-31 19:02:33 +0100
commitaa8c830d9b0a24b54c87a0300dde1e72e64cf0a9 (patch)
treea460d2899a5a11565aa5448f20ff209cc728696d /mysql-test/lib/mtr_io.pl
parent8e0113be8c2266773d58e1709abdb3352c40057a (diff)
downloadmariadb-git-aa8c830d9b0a24b54c87a0300dde1e72e64cf0a9.tar.gz
Improve the reading of .pid files from var/run
- Only read *.pid - Only allow it to contain a number mysql-test/lib/mtr_io.pl: Check that the value read from pidfile is a valid number consisting only of digits mysql-test/lib/mtr_process.pl: Only process .pid files in var/run dir and print a warning if other files are found there.
Diffstat (limited to 'mysql-test/lib/mtr_io.pl')
-rw-r--r--mysql-test/lib/mtr_io.pl12
1 files changed, 5 insertions, 7 deletions
diff --git a/mysql-test/lib/mtr_io.pl b/mysql-test/lib/mtr_io.pl
index a1d7ffe87d8..984d834486c 100644
--- a/mysql-test/lib/mtr_io.pl
+++ b/mysql-test/lib/mtr_io.pl
@@ -37,18 +37,16 @@ sub mtr_get_pid_from_file ($) {
open(FILE, '<', $pid_file_path)
or mtr_error("can't open file \"$pid_file_path\": $!");
+ # Read pid number from file
my $pid= <FILE>;
-
- chomp($pid) if defined $pid;
-
close FILE;
- return $pid if defined $pid && $pid ne '';
+ return $pid if $pid=~ /^(\d+)/;
- mtr_debug("Pid file '$pid_file_path' is empty. " .
- "Sleeping $timeout second(s)...");
+ mtr_debug("Pid file '$pid_file_path' does not yet contain pid number.\n" .
+ "Sleeping $timeout second(s) more...");
- sleep(1);
+ sleep($timeout);
}
mtr_error("Pid file '$pid_file_path' is corrupted. " .