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
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: Anatolii_Ivaniuk_CW at bmc dot com
New email:
PHP Version: OS:

 

 [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-2020 The PHP Group
All rights reserved.
Last updated: Fri Dec 04 18:01:23 2020 UTC