aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Iurt/Process.pm
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Iurt/Process.pm')
-rw-r--r--lib/Iurt/Process.pm28
1 files changed, 5 insertions, 23 deletions
diff --git a/lib/Iurt/Process.pm b/lib/Iurt/Process.pm
index 46b8de2..dc25f99 100644
--- a/lib/Iurt/Process.pm
+++ b/lib/Iurt/Process.pm
@@ -14,7 +14,6 @@ our @EXPORT = qw(
clean_process
check_pid
perform_command
- set_alarm_message
sudo
);
@@ -59,9 +58,7 @@ sub check_pid {
if ($time < time()-7200 || $state eq 'Z') {
my $i;
- my $msg = "another instance [$pid] is too old, killing it";
- set_alarm_message($msg);
- plog('WARN', $msg);
+ plog('WARN', "another instance [$pid] is too old, killing it");
while ($i < 5 && getpgrp $pid != -1) {
kill_for_good($pid);
@@ -105,18 +102,14 @@ sub fork_to_monitor {
my (@stat) = stat $logfile;
if ($stat[7] > $size_limit) {
# FIXME: we left runaway processes (eg: urpmi)
- my $msg = "Killing current command because of log size exceeding limit ($stat[7] > $config->{log_size_limit})";
- set_alarm_message($msg);
- plog('ERROR', $msg);
+ plog('ERROR', "Killing current command because of log size exceeding limit ($stat[7] > $config->{log_size_limit})");
kill 14, "-$parent_pid";
exit();
}
if ($opt{stalled_timeout} && $stat[9] && $stat[9] + $opt{stalled_timeout} < time()) {
# If nothing was written to the logfile for more than stalled_timeout, check if the system seems busy
if ((getload())[1] < 0.5) {
- my $msg = "Killing current command because it seems blocked";
- set_alarm_message($msg);
- plog('ERROR', $msg);
+ plog('ERROR', "Killing current command because it seems blocked");
kill 14, "-$parent_pid";
exit();
}
@@ -125,8 +118,7 @@ sub fork_to_monitor {
my $df = df $opt{log};
if ($df->{per} >= 99) {
# FIXME: we left runaway processes (eg: urpmi)
- set_alarm_message(my $msg = "Killing current command because running out of disk space at $opt{log} (only $df->{bavail}KB left)");
- plog('ERROR', $msg);
+ plog('ERROR', "Killing current command because running out of disk space at $opt{log} (only $df->{bavail}KB left)");
kill 14, "-$parent_pid";
exit();
}
@@ -210,13 +202,6 @@ sub generate_comment {
}
}
-my $alarm_message;
-
-sub set_alarm_message {
- my ($msg) = @_;
- $alarm_message = $msg;
-}
-
=head2 perform_command($command, $run, $config, %opt)
Run a command and check various running parameters such as log size, timeout...
@@ -268,9 +253,8 @@ sub perform_command {
eval {
# handle timeout:
- set_alarm_message("Timeout! (timeout was $opt{timeout})");
local $SIG{ALRM} = sub {
- print $alarm_message, "\n";
+ print "Timeout! (timeout was $opt{timeout})\n";
$kill = 1;
die "alarm\n"; # NB: \n required
};
@@ -306,7 +290,6 @@ sub perform_command {
$err = 0 if any { $_ == $err } @{$opt{error_ok}};
# kill pid watching log file size
- set_alarm_message("kill pid watching log file size");
kill_for_good($pid) if $pid;
if ($perl_err) { # timed out
@@ -382,7 +365,6 @@ sub kill_for_good {
my ($pid) = @_;
# try SIGALARM first:
- set_alarm_message("Killing current command because it seems blocked");
kill 14, $pid;
sleep 1;
waitpid(-1, POSIX::WNOHANG);