]> git.proxmox.com Git - pve-installer.git/blobdiff - Proxmox/Sys/Command.pm
sys: command: handle EINTR in run_command()
[pve-installer.git] / Proxmox / Sys / Command.pm
index e64e0ee6cda8f0d7fea822ef34accd9e85913ea4..6389b17e196aa2a908812522a14d9a9b278f7292 100644 (file)
@@ -134,10 +134,17 @@ sub run_command {
     $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
@@ -170,7 +177,7 @@ sub run_command {
 
     &$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;