]> git.proxmox.com Git - pve-installer.git/commitdiff
sys/command: double wait frequency and send SIGKILL once after 0.5s
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Mon, 26 Feb 2024 19:40:14 +0000 (20:40 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Mon, 26 Feb 2024 19:46:59 +0000 (20:46 +0100)
100 ms is quite plenty, while we would be better of using a event
based wait, i.e., dropping the WNOHANG, that would also mean handling
the time out via alarm, EINTR checking and quite a bit other stuff
making this more convoluted, so for now just go faster..

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
Proxmox/Sys/Command.pm

index d2dcd42385f585fa10e0ed9f8d74d92834f61185..841d0b037277f658c204ca28dc28c8e32d7d1a3a 100644 (file)
@@ -53,13 +53,13 @@ my sub wait_for_process {
 
     kill('TERM', $pid) if $params{kill};
 
-    my $timeout = ($params{timeout} // 5) * 10; # waiting 0.1 secs per loop
+    my $timeout = ($params{timeout} // 5) * 20; # waiting 0.05 secs per loop
     for (0 .. $timeout) {
        my $terminated = waitpid($pid, WNOHANG);
        return $? if $terminated > 0;
 
-       usleep(100_000) if $_ != $timeout; # sleep 0.1 sec, on all but last round
-       kill('KILL', $pid) if $params{kill} && $_ == 1; # just first round
+       usleep(50_000) if $_ != $timeout; # sleep 0.05 sec, on all but last round
+       kill('KILL', $pid) if $params{kill} && $_ == 10; # just once after 0.5s
     }
 
     log_warn("failed to kill child pid $pid, probably stuck in D-state?\n");