$select->add($error);
my ($ostream, $logout) = ('', '', '');
+ my $caught_sig;
while ($select->count) {
my @handles = $select->can_read (0.2);
+ # If we catch a signal, stop processing & clean up
+ if ($!{EINTR}) {
+ $caught_sig = 1;
+ last;
+ }
+
Proxmox::UI::process_events();
next if !scalar (@handles); # timeout
&$func($logout) if $func;
- my $ec = wait_for_process($pid);
+ my $ec = wait_for_process($pid, kill => $caught_sig);
# behave like standard system(); returns -1 in case of errors too
return ($ec // -1) if $noout;
});
is($ret, '', 'using CMD_FINISHED');
+# https://bugzilla.proxmox.com/show_bug.cgi?id=4872
+my $prev;
+eval {
+ local $SIG{ALRM} = sub { die "timed out!\n" };
+ $prev = alarm(1);
+ $ret = run_command('sleep 5');
+};
+alarm($prev);
+
+is($@, "timed out!\n", 'SIGALRM interaction');
+
# Check the log for errors/warnings
my $log = file_read_all($log_file->filename);
ok($log !~ m/(WARN|ERROR): /, 'no warnings or errors logged');