Bug #80080 [Fbk->NoF]: stream_get_contents is never completed
| From: | php-bugs at lists dot php dot net | Date: | Sun, 07 Nov 2021 04:22:08 +0000 |
| Subject: | Bug #80080 [Fbk->NoF]: stream_get_contents is never completed | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-237591@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=80080&edit=1
ID: 80080
Updated by: php-bugs@lists.php.net
Reported by: clark at electrobeat dot dk
Summary: stream_get_contents is never completed
-Status: Feedback
+Status: No Feedback
Type: Bug
Package: Streams related
Operating System: Debian 10
PHP Version: 7.3.22
Assigned To: cmb
Private report: N
New Comment:
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
Previous Comments:
------------------------------------------------------------------------
[2021-10-26 11:11:38] cmb@php.net
Does still still happen to you with any of the actively supported
PHP versions[1]?
If so (which is what I assume), I think you need to make the pipes
non-blocking (stream_set_blocking), and implement a proper
stream_select().
[1] <https://www.php.net/supported-versions.php>
------------------------------------------------------------------------
[2020-09-09 09:22:42] clark at electrobeat dot dk
Description:
------------
Sometimes I experience that stream_get_contents never completes executing
In this case a PDF file is processed via poppler's pdftops. The PDF contains some errors though
but when running the command directly in a terminal it completes and returns
The code only prints "opened" but never reach "ouput done"
The PDF can be found here
https://docdro.id/fHlIxBS
Test script:
---------------
$syntax = '/var/bin/poppler-0.79.0/build/utils/pdftops file.pdf file.ps';
$pipes = [];
$process = proc_open($syntax, [
0 => ['pipe', 'r'], // stdin
1 => ['pipe', 'w'], // stdout
2 => ['pipe', 'w'] // stderr
], $pipes);
fclose($pipes[0]);
echo "opened\n";
$output = stream_get_contents($pipes[1]);
echo "output done\n";
$stderr = stream_get_contents($pipes[2]);
echo "err done\n";
foreach($pipes as $pipe){
if(is_resource($pipe)){
fclose($pipe);
}
}
$exitcode = proc_close($process);
echo "err: $stderr\n";
echo "out: $output\n";
Expected result:
----------------
opened
output done
err done
err:
output:
Actual result:
--------------
opened
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=80080&edit=1