Test --verbose. Remove global default OPT_VERBOSE from log_warn_die.sh so tool's option can set it.

This commit is contained in:
Daniel Nichter
2013-01-24 11:13:39 -07:00
parent 11fa16382c
commit b196f50e60
6 changed files with 162 additions and 35 deletions

View File

@@ -58,7 +58,6 @@ our @EXPORT = qw(
wait_until
wait_for
wait_until_slave_running
wait_until_no_lag
test_log_parser
test_protocol_parser
test_packet_parser
@@ -325,6 +324,39 @@ sub wait_for_sh {
);
};
sub kill_program {
my (%args) = @_;
my $pid_file = $args{pid_file};
my $pid = $args{pid};
if ( $pid_file ) {
chomp($pid = `cat $pid_file 2>/dev/null`);
}
if ( $pid ) {
PTDEVDEBUG && _d('Killing PID', $pid);
kill(15, $pid);
wait_until(
sub { my $is_alive = kill(0, $pid); return !$is_alive; },
1.5, # sleep between tries
15, # max time to try
);
if ( kill(0, $pid) ) {
warn "PID $pid did not die; using kill -9\n";
kill(9, $pid);
}
}
else {
PTDEVDEBUG && _d('No PID to kill');
}
if ( $pid_file && -f $pid_file ) {
PTDEVDEBUG && _d('Removing PID file', $pid_file);
unlink $pid_file;
}
}
sub not_running {
my ($cmd) = @_;
PTDEVDEBUG && _d('Wait until not running:', $cmd);