php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #72515 Proc_open does not work with sockets
Submitted: 2016-06-29 10:15 UTC Modified: 2016-07-10 04:22 UTC
From: Anatolii_Ivaniuk_CW at bmc dot com Assigned:
Status: No Feedback Package: Streams related
PHP Version: 5.5.37 OS: Windows
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
MUST BE VALID
Solve the problem:
39 + 47 = ?
Subscribe to this entry?

 
 [2016-06-29 10:15 UTC] Anatolii_Ivaniuk_CW at bmc dot com
Description:
------------
Starting from version 5.5.18 proc_open with socket handles does not wait for input. Everything work fine in 5.5.17 version of php. If I open up a child process and pass in socket to handle new clients commands in 5.5.17 version script is waiting for input and prints it. But in 5.5.18 and up till 7.0.4 this approach does not work anymore for windows and works fine on linux environments.

Test script:
---------------
proc.php 
########################################
$errno = '';
$errstr = '';
$socket = stream_socket_server("tcp://0.0.0.0:$port",$errno,$errstr);
$client = @stream_socket_accept($socket,1);
$handles = array(
			0 => $socket,
			1 => $socket,
			2 => STDERR,
		);
$pipes = array();
$h = proc_open('php.exe file.php',$handles,$pipes);

file.php
#####################################
echo(">");
if (($cmd = fgets(STDIN,2048)) === false)
		return;
$cmd = trim($cmd);
echo($cmd);




Expected result:
----------------
Child process can read and write to socket.

Actual result:
--------------
Child process terminates as $cmd = fgets(STDIN,2048) is always false.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-07-01 15:53 UTC] ab@php.net
-Status: Open +Status: Feedback
 [2016-07-01 15:53 UTC] ab@php.net
Thanks for the report. I'm currently unable to reproduce the issue with the latest 7.0 tree. The code seems correct, but i guess you should use PHP_BINARY instead of php.exe hardcoded. Anyway, could you please give some further info on how to reproduce?

Thanks.
 [2016-07-10 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-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 17:01:29 2024 UTC