php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #68668 popen does not pass variables
Submitted: 2014-12-28 21:22 UTC Modified: 2014-12-30 11:26 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: sandor_hadas at hotmail dot com Assigned:
Status: Not a bug Package: Output Control
PHP Version: 5.6.4 OS: Windows 7 x64
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: sandor_hadas at hotmail dot com
New email:
PHP Version: OS:

 

 [2014-12-28 21:22 UTC] sandor_hadas at hotmail dot com
Description:
------------
The following code executes properly on linux while it fails with both 32bit and 64bit windows. The problem on windows is that the "abc" string is not received in the x.php file while outer.php reports that the appropriate number of bytes were successfully written.



Test script:
---------------
outer.php (this is executed)
$handle = popen('php x.php', 'w');
$write = fwrite($handle, "abc\r\n");
fflush($handle);
echo $write;
sleep(10);
pclose($handle);

x.php (this receives "abc" on linux, received nothing on windows)
do {
    $c = fgets(STDIN);
    print($c);
} while (!feof(STDIN));

sleep(10);

Expected result:
----------------
x.php receives the 5 characters fwrite sent.

Actual result:
--------------
Data not received.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2014-12-30 11:26 UTC] ab@php.net
-Status: Open +Status: Not a bug
 [2014-12-30 11:26 UTC] ab@php.net
You seem to have PHP not available on the %path%. Note that your command will expand to 

cmd /c "php x.php"

That means the returned $handle will still be valid, as cmd is always available. Same on linux actually. So you could use PHP_BINARY or better define an exact path to php.exe on your system. And you should be always checking the error messaged returned from the shell.

Thanks.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Dec 27 05:01:27 2024 UTC