summaryrefslogtreecommitdiff
path: root/mysql-test/lib/mtr_process.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_process.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_process.pl')
-rw-r--r--mysql-test/lib/mtr_process.pl40
1 files changed, 25 insertions, 15 deletions
diff --git a/mysql-test/lib/mtr_process.pl b/mysql-test/lib/mtr_process.pl
index affe8278376..048c336f8a3 100644
--- a/mysql-test/lib/mtr_process.pl
+++ b/mysql-test/lib/mtr_process.pl
@@ -438,25 +438,35 @@ sub mtr_kill_leftovers () {
while ( my $elem= readdir(RUNDIR) )
{
- my $pidfile= "$rundir/$elem";
-
- if ( -f $pidfile )
+ # Only read pid from files that end with .pid
+ if ( $elem =~ /.*[.]pid$/)
{
- mtr_debug("Processing PID file: '$pidfile'...");
- my $pid= mtr_get_pid_from_file($pidfile);
+ my $pidfile= "$rundir/$elem";
- mtr_debug("Got pid: $pid from file '$pidfile'");
+ if ( -f $pidfile )
+ {
+ mtr_debug("Processing PID file: '$pidfile'...");
- if ( $::glob_cygwin_perl or kill(0, $pid) )
- {
- mtr_debug("There is process with pid $pid -- scheduling for kill.");
- push(@pids, $pid); # We know (cygwin guess) it exists
- }
- else
- {
- mtr_debug("There is no process with pid $pid -- skipping.");
- }
+ my $pid= mtr_get_pid_from_file($pidfile);
+
+ mtr_debug("Got pid: $pid from file '$pidfile'");
+
+ if ( $::glob_cygwin_perl or kill(0, $pid) )
+ {
+ mtr_debug("There is process with pid $pid -- scheduling for kill.");
+ push(@pids, $pid); # We know (cygwin guess) it exists
+ }
+ else
+ {
+ mtr_debug("There is no process with pid $pid -- skipping.");
+ }
+ }
+ }
+ else
+ {
+ mtr_warning("Found non pid file $elem in $rundir");
+ next;
}
}
closedir(RUNDIR);