aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThierry Vignaud <thierry.vignaud@gmail.com>2019-08-07 14:35:23 +0200
committerThierry Vignaud <thierry.vignaud@gmail.com>2019-08-07 14:35:30 +0200
commit162884bd41d51530fee5376fa661fcb1ba245c01 (patch)
treedb89e6d200fc4f860051be869abfac6cf7223777
parent0d78ec170900df342301a5bbe44e7ca883cc0db1 (diff)
Revert "fix timeout message when killing for other reason"HEADmaster
This reverts commit 0d78ec170900df342301a5bbe44e7ca883cc0db1. Rationale: That will not work as intended b/c the message is set in the child process while it gets logged in the parent
-rw-r--r--NEWS2
-rwxr-xr-xiurt6
-rw-r--r--lib/Iurt/Process.pm28
3 files changed, 7 insertions, 29 deletions
diff --git a/NEWS b/NEWS
index b122951..82d25c1 100644
--- a/NEWS
+++ b/NEWS
@@ -1,5 +1,3 @@
-- fix timeout message when killing for other reason
-
0.7.8.1
- no changes, fixing bad release
diff --git a/iurt b/iurt
index 9008bdf..95aa89c 100755
--- a/iurt
+++ b/iurt
@@ -40,7 +40,7 @@ use URPM;
use Iurt::Urpmi;
use Iurt::Chroot qw(add_local_user create_temp_chroot remove_chroot create_build_chroot clean_chroot);
-use Iurt::Process qw(perform_command kill_for_good set_alarm_message sudo);
+use Iurt::Process qw(perform_command kill_for_good sudo);
use Iurt::Mail qw(sendmail);
use Iurt::Util qw(plog_init plog);
use File::NCopy qw(copy);
@@ -1082,11 +1082,9 @@ sub check_pid {
my $state = `ps h -o state $pid`;
chomp $state;
if ($time < time()-36000 || $state eq 'Z') {
- my $msg = "an other iurt pid $pid is running for a very long time or is zombie, killing it";
- plog($msg);
+ plog("an other iurt pid $pid is running for a very long time or is zombie, killing it");
my $i;
while ($i < 5 && getpgrp $pid != -1) {
- set_alarm_message($msg);
kill_for_good($pid);
$i++;
sleep 1;
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);