Bug #80080 [Com]: stream_get_contents is never completed

From: Date: Mon, 08 Feb 2021 05:41:56 +0000
Subject: Bug #80080 [Com]: stream_get_contents is never completed
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-231999@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 Comment by: lilliegreene19 at gmail dot com Reported by: clark at electrobeat dot dk Summary: stream_get_contents is never completed Status: Open Type: Bug Package: Sockets related Operating System: Debian 10 PHP Version: 7.3.22 Block user comment: N Private report: N New Comment: Issue has been solved by using temporary files instead of stream pipes in proc_open(). Furthermore, PhantomJs 1.9.8 with php-phantomjs SHOULD NOT be installed as it gives issues with parsing the data out of the files. { "repositories": [ { "type": "vcs", "url": "https://github.com/GiampaoloFalqui/php-phantomjs" } ], "require": { "jonnyw/php-phantomjs": "3.*" } }, https://www.prepaidcardstatus.net/ Previous Comments: ------------------------------------------------------------------------ [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

« previous php.bugs (#231999) next »