]> git.proxmox.com Git - pve-manager.git/commitdiff
pvescheduler: catch errors in forked childs
authorDominik Csapak <d.csapak@proxmox.com>
Thu, 18 Nov 2021 13:28:29 +0000 (14:28 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Mon, 22 Nov 2021 16:19:12 +0000 (17:19 +0100)
if '$sub' dies, the error handler of PVE::Daemon triggers, which
initiates a shutdown of the child, resulting in confusing error logs
(e.g. 'got shutdown request, signal running jobs to stop')

instead, run it under 'eval' and print the error to the sylog instead

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
PVE/Service/pvescheduler.pm

index 9f5c4515e59691021cc8d4f45e023422b17dfa14..d4f7370295b4312533ab5816a10d5771b0fcc5be 100755 (executable)
@@ -47,7 +47,12 @@ sub run {
            die "fork failed: $!\n";
        } elsif ($child == 0) {
            $self->after_fork_cleanup();
-           $sub->();
+           eval {
+               $sub->();
+           };
+           if (my $err = $@) {
+               syslog('err', "ERROR: $err");
+           }
            POSIX::_exit(0);
        }