php.net |  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: -
From: clark at electrobeat dot dk Assigned:
Status: Open Package: Sockets related
PHP Version: 7.3.22 OS: Debian 10
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: clark at electrobeat dot dk
New email:
PHP Version: OS:

 

 [2020-09-09 09:22 UTC] 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

Patches

Add a Patch

Pull Requests

Add a Pull Request

 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Sun Oct 25 03:01:24 2020 UTC