Skip to content

Commit 859d4a1

Browse files
bug #45103 [Process] Avoid calling fclose on an already closed resource (Seldaek)
This PR was squashed before being merged into the 4.4 branch. Discussion ---------- [Process] Avoid calling fclose on an already closed resource | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | Fix #... <!-- prefix each issue number with "Fix #", no need to create an issue if none exist, explain below instead --> | License | MIT | Doc PR | symfony/symfony-docs#... <!-- required for new features --> I got this in Composer while interrupting an install process with Ctrl-C. ``` PHP Fatal error: Uncaught TypeError: fclose(): supplied resource is not a valid stream resource in /var/www/composer/vendor/symfony/process/Pipes/AbstractPipes.php:50 Stack trace: #0 /var/www/composer/vendor/symfony/process/Pipes/AbstractPipes.php(50): fclose() #1 /var/www/composer/vendor/symfony/process/Pipes/UnixPipes.php(50): Symfony\Component\Process\Pipes\AbstractPipes->close() #2 [internal function]: Symfony\Component\Process\Pipes\UnixPipes->__destruct() #3 {main} thrown in /var/www/composer/vendor/symfony/process/Pipes/AbstractPipes.php on line 50 ``` I am assuming it's due to a process which was not closed properly, which is very likely given we run a bunch of them concurrently.. It's pretty hard to debug as it's also hard to reproduce, so I am not sure what to do except handle this case gracefully in the close/__destruct function and hope that at least lets it clean up processes without crashing this way. Commits ------- a9e43a7 [Process] Avoid calling fclose on an already closed resource
2 parents 7eea1cb + a9e43a7 commit 859d4a1

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/Symfony/Component/Process/Pipes/AbstractPipes.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,9 @@ public function __construct($input)
4747
public function close()
4848
{
4949
foreach ($this->pipes as $pipe) {
50-
fclose($pipe);
50+
if (\is_resource($pipe)) {
51+
fclose($pipe);
52+
}
5153
}
5254
$this->pipes = [];
5355
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy