]> git.proxmox.com Git - pve-installer.git/commit
sys: command: factor out kill() + waitpid() from run_command()
authorChristoph Heiss <c.heiss@proxmox.com>
Tue, 13 Feb 2024 15:13:59 +0000 (16:13 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Fri, 23 Feb 2024 13:19:56 +0000 (14:19 +0100)
commit152bbef439c024207df63600d34da35b79f1ae5c
tree0dc69c3f52b506b8f8766da20859020ef1f43221
parent479b052450b00434b263d4c760220bb48a971a24
sys: command: factor out kill() + waitpid() from run_command()

This moves the kill() + waitpid() combo into a separate subroutine,
avoiding open-coding that sequence. wait_for_process() also handles
properly unkillable process (e.g. in D-state) and avoids completely
locking up the installer in such cases. See [0].

For the latter case, a timeout exists (with a default of 5 seconds) in
which to wait for the process to exit after sending an optional
TERM/KILL signal.

Also while at it, add a few basic tests for run_command().

[0] https://lists.proxmox.com/pipermail/pve-devel/2024-February/061697.html

Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
Proxmox/Sys/Command.pm
test/Makefile
test/run-command.pl [new file with mode: 0755]