Explorar o código

Fix in resetStd to close STDOUT and STDERR

Anton %!s(int64=2) %!d(string=hai) anos
pai
achega
c1b0308e62
Modificáronse 1 ficheiros con 12 adicións e 1 borrados
  1. 12 1
      src/Worker.php

+ 12 - 1
src/Worker.php

@@ -1326,6 +1326,18 @@ class Worker
             return;
         }
 
+        if (is_resource(STDOUT)) {
+            fclose(STDOUT);
+        }
+
+        if (is_resource(STDERR)) {
+            fclose(STDERR);
+        }
+
+        if (is_resource(static::$outputStream)) {
+            fclose(static::$outputStream);
+        }
+
         set_error_handler(static fn (): bool => true);
         $stdOutStream = fopen(static::$stdoutFile, 'a');
         restore_error_handler();
@@ -1334,7 +1346,6 @@ class Worker
             return;
         }
 
-        fclose(static::$outputStream);
         static::$outputStream = $stdOutStream;
 
         // Fix standard output cannot redirect of PHP 8.1.8's bug