#1 mkill: post-killing slow process next sleep too long

open
nobody
Install (1)
5
2007-09-23
2007-09-23
Hedge
No

mkill - excellent tool! Thank you:)

Now, during refresh_screen function the variable $max is set to be the amount of time to wait during the next sleep cycle. However, if a process is killed during refresh_screen then $max gets erroneously set to the same value as $opt_slow. In this state the sleep cycle will run for $opt_slow seconds ... but this state ignores all other queries whose running time are _coming close to $opt_slow time_.

Thus a situation occurs when a process will not be killed for ($opt_slow + $opt_slow - 1) seconds.

The following is a patch to mkill.PL (run make install after making the patch). Better Perl programmers may make this a neater solution :) -

find:
sub refresh_screen {
my $max = 0;

change to:
sub refresh_screen {
my $max = 0;
my $prevmax = 0;

find:
$max = $data if $col eq "Time" && $data > $max;

change to:
$max = $data if $col eq "Time" && $data > $max;
$prevmax = $max if $max > $prevmax && $max < $opt_slow;

find:
return $max;

change to:
if ($max<$opt_slow) {
return $max;
} else {
return $prevmax;
}

Discussion