do not close STDIN if rune in foreground
[pve-access-control.git] / PVE / RPCEnvironment.pm
index 5806107..4cacd52 100644 (file)
@@ -531,13 +531,17 @@ sub fork_worker {
            # same algorythm as used inside SA
            # STDIN = /dev/null
            my $fd = fileno (STDIN);
-           close STDIN;
-           POSIX::close(0) if $fd != 0;
 
-           die "unable to redirect STDIN - $!" 
-               if !open(STDIN, "</dev/null");
+           if (!$sync) {
+               close STDIN;
+               POSIX::close(0) if $fd != 0;
+
+               die "unable to redirect STDIN - $!" 
+                   if !open(STDIN, "</dev/null");
+
+               $outfh = PVE::Tools::upid_open($upid);
+           }
 
-           $outfh = PVE::Tools::upid_open($upid) if !$sync;
 
            # redirect STDOUT
            $fd = fileno(STDOUT);