mirror of
https://git.proxmox.com/git/pve-common
synced 2025-07-14 02:24:33 +00:00
fork_worker: refactor child exit
* factor out duplicated code. * drop final kill(-9, $$), since the POSIX:_exit call does not return (see man 2 _exit). Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
This commit is contained in:
parent
7571d25b3d
commit
edbb302ec8
@ -579,22 +579,21 @@ sub fork_worker {
|
||||
}
|
||||
&$function($upid);
|
||||
};
|
||||
my ($msg, $exitcode);
|
||||
my $err = $@;
|
||||
if ($err) {
|
||||
chomp $err;
|
||||
$err =~ s/\n/ /mg;
|
||||
syslog('err', $err);
|
||||
my $msg = "TASK ERROR: $err\n";
|
||||
POSIX::write($resfh, $msg, length($msg));
|
||||
POSIX::close($resfh) if $sync;
|
||||
POSIX::_exit(-1);
|
||||
$msg = "TASK ERROR: $err\n";
|
||||
$exitcode = -1;
|
||||
} else {
|
||||
my $msg = "TASK OK\n";
|
||||
POSIX::write($resfh, $msg, length($msg));
|
||||
POSIX::close($resfh) if $sync;
|
||||
POSIX::_exit(0);
|
||||
$msg = "TASK OK\n";
|
||||
$exitcode = 0;
|
||||
}
|
||||
kill(-9, $$);
|
||||
POSIX::write($resfh, $msg, length($msg));
|
||||
POSIX::close($resfh) if $sync;
|
||||
POSIX::_exit($exitcode);
|
||||
}
|
||||
|
||||
# parent
|
||||
|
Loading…
Reference in New Issue
Block a user