]> git.proxmox.com Git - pve-common.git/blobdiff - data/PVE/Tools.pm
implement afterfork callback
[pve-common.git] / data / PVE / Tools.pm
index 3212595fdd8306021d0fa30ceb6b87d72ff93413..20fc1ea3ad0f73c1ee4f03b8d6b93586833b6e5b 100644 (file)
@@ -236,6 +236,7 @@ sub run_command {
     my $logfunc;
     my $input;
     my $output;
+    my $afterfork;
 
     eval {
 
@@ -256,6 +257,8 @@ sub run_command {
                $errfunc = $param{$p};
            } elsif ($p eq 'logfunc') {
                $logfunc = $param{$p};
+           } elsif ($p eq 'afterfork') {
+               $afterfork = $param{$p};
            } else {
                die "got unknown parameter '$p' for run_command\n";
            }
@@ -316,6 +319,8 @@ sub run_command {
        local $SIG{ALRM} = sub { die "got timeout\n"; } if $timeout;
        $oldtimeout = alarm($timeout) if $timeout;
 
+       &$afterfork() if $afterfork;
+
        if (ref($writer)) {
            print $writer $input if defined $input;
            close $writer;