mirror of
https://git.proxmox.com/git/pve-common
synced 2025-08-11 16:09:26 +00:00
run_fork_with_timeout: handle SIGTERM
when stopping a worker while doing a run_fork_with_timeout, we want to handle that there and send the child the SIGTERM so that it can clean up for this we have to use readline_nointr, because the read from the pipe gets interrupted by the signal this partially fixes #1874 as we now correctly clean up the new disk, except if it is on lvm/lvmthin (possibly other storages as well), and use the old disk in the config Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
This commit is contained in:
parent
e03a836591
commit
2e353dfb5f
@ -922,7 +922,6 @@ sub run_fork_with_timeout {
|
|||||||
|
|
||||||
# avoid leaving a zombie if the parent gets interrupted
|
# avoid leaving a zombie if the parent gets interrupted
|
||||||
my $sig_received;
|
my $sig_received;
|
||||||
local $SIG{INT} = sub { $sig_received++; };
|
|
||||||
|
|
||||||
my $child = fork();
|
my $child = fork();
|
||||||
if (!defined($child)) {
|
if (!defined($child)) {
|
||||||
@ -946,11 +945,17 @@ sub run_fork_with_timeout {
|
|||||||
POSIX::_exit(0);
|
POSIX::_exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
local $SIG{INT} = sub { $sig_received++; };
|
||||||
|
local $SIG{TERM} = sub {
|
||||||
|
$error //= "interrupted by unexpected signal\n";
|
||||||
|
kill('TERM', $child);
|
||||||
|
};
|
||||||
|
|
||||||
$pipe_out->reader();
|
$pipe_out->reader();
|
||||||
|
|
||||||
my $readvalues = sub {
|
my $readvalues = sub {
|
||||||
local $/ = undef;
|
local $/ = undef;
|
||||||
my $child_res = decode_json(scalar<$pipe_out>);
|
my $child_res = decode_json(readline_nointr($pipe_out));
|
||||||
$res = $child_res->{result};
|
$res = $child_res->{result};
|
||||||
$error = $child_res->{error};
|
$error = $child_res->{error};
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user