php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #54004 proc_open() should accept php:// wrappers for file
Submitted: 2011-02-13 00:59 UTC Modified: 2011-02-15 11:31 UTC
From: asari at users dot sourceforge dot net Assigned:
Status: Not a bug Package: Unknown/Other Function
PHP Version: trunk-SVN-2011-02-12 (snap) OS: Linux (Ubuntu x86)
Private report: No CVE-ID: None
 [2011-02-13 00:59 UTC] asari at users dot sourceforge dot net
Description:
------------
---
From manual page: http://www.php.net/function.proc-open
---

proc_open() can attach files for the child process' standard input/output/error, 
but can't attach php:// wrapper. As far as I tried, http:// wrapper works fine.

If wrappers can be used for proc_open(), in many cases I think we can avoid 
complicated stream_select() programming using non-blocking i/o, as 
dk at brightbyte dot de does in http://www.php.net/function.shell-exec.php .

Test script:
---------------
<?php
header("Content-Type: application/octet-stream");
proc_close(proc_open("zcat",
array(
   0 => array("file", "php://input", "r"),
   1 => array("file", "php://output", "w"),
   2 => array("file", "/dev/null", "a")
), $pipes));


Expected result:
----------------
Ungzip'ed content should be displayed when HTTP POST with gzip'ed request body or 
when executed in CLI with gzip'ed standard input.

Actual result:
--------------
$ ~/local/php-trunk-20110212/bin/php -v
PHP 5.3.99-dev (cli) (built: Feb 13 2011 08:00:27) 
Copyright (c) 1997-2011 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2011 Zend Technologies
$ ~/local/php-trunk-20110212/bin/php zcat.php < /usr/share/doc/php5/TODO.gz 

Warning: proc_open(): cannot represent a stream of type Input as a File 
Descriptor in /path/to/zcat.php on line 8

Warning: proc_close() expects parameter 1 to be resource, boolean given in 
/path/to/zcat.php on line 8

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-02-15 11:31 UTC] cataphract@php.net
-Status: Open +Status: Bogus
 [2011-02-15 11:31 UTC] cataphract@php.net
This cannot be done for php://output and, in most cases (though for the CLI it could be done), for php://input. The reason is that the output buffering chain cannot be written to through a simple file descriptor.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Dec 05 23:01:30 2024 UTC