|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #80080 stream_get_contents is never completed
Submitted: 2020-09-09 09:22 UTC Modified: 2021-11-07 04:22 UTC
From: clark at electrobeat dot dk Assigned: cmb (profile)
Status: No Feedback Package: Streams related
PHP Version: 7.3.22 OS: Debian 10
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2020-09-09 09:22 UTC] clark at electrobeat dot dk
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

Test script:
$syntax = '/var/bin/poppler-0.79.0/build/utils/pdftops file.pdf';

$pipes = [];
$process = proc_open($syntax, [
	0 => ['pipe', 'r'],	// stdin
	1 => ['pipe', 'w'],	// stdout
	2 => ['pipe', 'w']	// stderr
], $pipes);

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){

$exitcode = proc_close($process);

echo "err: $stderr\n";
echo "out: $output\n";

Expected result:
output done
err done

Actual result:


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2021-10-26 11:11 UTC]
-Status: Open +Status: Feedback -Package: Sockets related +Package: Streams related -Assigned To: +Assigned To: cmb
 [2021-10-26 11:11 UTC]
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

[1] <>
 [2021-11-07 04:22 UTC] php-bugs at lists dot php dot net
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.
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Wed Feb 01 23:05:51 2023 UTC