|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #44667 proc_open does not handle pipes with the mode 'wb' correctly
Submitted: 2008-04-08 03:21 UTC Modified: 2008-04-08 09:47 UTC
From: mike at silverorange dot com Assigned: jani (profile)
Status: Closed Package: Program Execution
PHP Version: 5.2CVS-2008-04-08 (CVS) OS: *
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.
Block user comment
Status: Assign to:
Bug Type:
From: mike at silverorange dot com
New email:
PHP Version: OS:


 [2008-04-08 03:21 UTC] mike at silverorange dot com
proc_open.c checks if the mode parameter != "w" instead of checking the first character of the mode parameter. This prevents the mode 'wb' from working properly. 

Reproduce code:

$pipes = array();

$descriptor_spec = array(
    0 => array('pipe', 'rb'),
    1 => array('pipe', 'wb'),

$proc = proc_open('cat', $descriptor_spec, $pipes);

fwrite($pipes[0], 'Hello', 5);

$result = fread($pipes[1], 5);


echo "Result is: ", $result, "\n";


Expected result:
Result is: Hello

Actual result:
on stderr:
cat: write error: Bad file descriptor

on stdout:
Result is:


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2008-04-08 08:22 UTC]
Fixed, need to merge around.
 [2008-04-08 09:47 UTC]
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
Thank you for the report, and for helping us make PHP better.

PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Wed May 31 16:03:37 2023 UTC