#39982 [NEW]: when used inside a function, proc_open generated pipes are closed upon return

Ask a Question related to PHP Bugs, Design and Development.

  1. #1

    Default #39982 [NEW]: when used inside a function, proc_open generated pipes are closed upon return

    From: federico at galassi dot net
    Operating system: gentoo linux
    PHP version: 5.2.0
    PHP Bug Type: Program Execution
    Bug description: when used inside a function, proc_open generated pipes are closed upon return

    Description:
    ------------
    When calling proc_open inside the body
    of a function, pipes generated don't survive
    function's lifespan. resource is still there
    but stream is closed.

    Reproduce code:
    ---------------
    function foobar() {
    $proc = proc_open(
    "/usr/bin/php",
    array(
    0 => array('pipe', 'r'),
    1 => array('pipe', 'w'),
    2 => array('pipe', 'w')
    ),
    $pipes
    );
    var_dump($pipes);
    return $pipes;
    }
    $should_be_pipes = foobar();
    var_dump($should_be_pipes);

    Expected result:
    ----------------
    array(3) {
    [0]=>
    resource(6) of type (stream)
    [1]=>
    resource(7) of type (stream)
    [2]=>
    resource(8) of type (stream)
    }
    array(3) {
    [0]=>
    resource(6) of type (stream)
    [1]=>
    resource(7) of type (stream)
    [2]=>
    resource(8) of type (stream)
    }

    Actual result:
    --------------
    array(3) {
    [0]=>
    resource(6) of type (stream)
    [1]=>
    resource(7) of type (stream)
    [2]=>
    resource(8) of type (stream)
    }
    array(3) {
    [0]=>
    resource(6) of type (Unknown)
    [1]=>
    resource(7) of type (Unknown)
    [2]=>
    resource(8) of type (Unknown)
    }

    --
    Edit bug report at [url]http://bugs.php.net/?id=39982&edit=1[/url]
    --
    Try a CVS snapshot (PHP 4.4): [url]http://bugs.php.net/fix.php?id=39982&r=trysnapshot44[/url]
    Try a CVS snapshot (PHP 5.2): [url]http://bugs.php.net/fix.php?id=39982&r=trysnapshot52[/url]
    Try a CVS snapshot (PHP 6.0): [url]http://bugs.php.net/fix.php?id=39982&r=trysnapshot60[/url]
    Fixed in CVS: [url]http://bugs.php.net/fix.php?id=39982&r=fixedcvs[/url]
    Fixed in release: [url]http://bugs.php.net/fix.php?id=39982&r=alreadyfixed[/url]
    Need backtrace: [url]http://bugs.php.net/fix.php?id=39982&r=needtrace[/url]
    Need Reproduce Script: [url]http://bugs.php.net/fix.php?id=39982&r=needscript[/url]
    Try newer version: [url]http://bugs.php.net/fix.php?id=39982&r=oldversion[/url]
    Not developer issue: [url]http://bugs.php.net/fix.php?id=39982&r=support[/url]
    Expected behavior: [url]http://bugs.php.net/fix.php?id=39982&r=notwrong[/url]
    Not enough info: [url]http://bugs.php.net/fix.php?id=39982&r=notenoughinfo[/url]
    Submitted twice: [url]http://bugs.php.net/fix.php?id=39982&r=submittedtwice[/url]
    register_globals: [url]http://bugs.php.net/fix.php?id=39982&r=globals[/url]
    PHP 3 support discontinued: [url]http://bugs.php.net/fix.php?id=39982&r=php3[/url]
    Daylight Savings: [url]http://bugs.php.net/fix.php?id=39982&r=dst[/url]
    IIS Stability: [url]http://bugs.php.net/fix.php?id=39982&r=isapi[/url]
    Install GNU Sed: [url]http://bugs.php.net/fix.php?id=39982&r=gnused[/url]
    Floating point limitations: [url]http://bugs.php.net/fix.php?id=39982&r=float[/url]
    No Zend Extensions: [url]http://bugs.php.net/fix.php?id=39982&r=nozend[/url]
    MySQL Configuration Error: [url]http://bugs.php.net/fix.php?id=39982&r=mysqlcfg[/url]
    federico at galassi dot net Guest

  2. Similar Questions and Discussions

    1. return() inside eval
      This works as needed: #!/usr/local/bin/perl use strict; use Exception::Class( 'Exception' ); sub test() { eval { return( param1 => 'first',...
    2. #24967 [Bgs]: fopen when placed within a function causes function to return
      ID: 24967 User updated by: laurie at oneuponedown dot co dot uk Reported By: laurie at oneuponedown dot co dot uk Status: ...
    3. #24967 [NEW]: fopen when placed within a function causes function to return
      From: laurie at oneuponedown dot co dot uk Operating system: Linux PHP version: 4.3.2 PHP Bug Type: *Directory/Filesystem...
    4. Photoshp.exe has generated erros and will be closed (PS6.0.1)
      Hi! My PS6.0.1 is not inicializing. it appears an dialog box with the message: "Program Error. Photoshp.exe has generated erros and will be...
    5. Function/Global var to return name of calling function?
      I'm sure I saw this somewhere but can't remember where and can't find it now... Is there a PHP function or global variable that will return name...
  3. #2

    Default #39982 [Opn->Bgs]: when used inside a function, proc_open generated pipes are closed upon return

    ID: 39982
    Updated by: [email]tony2001@php.net[/email]
    Reported By: federico at galassi dot net
    -Status: Open
    +Status: Bogus
    Bug Type: Program Execution
    Operating System: gentoo linux
    PHP Version: 5.2.0
    New Comment:

    The $pipes are dependant resources of the $proc, so if $proc dies, they
    are closed too.
    Return both $proc and $pipes and everything will be ok.


    Previous Comments:
    ------------------------------------------------------------------------

    [2006-12-29 01:13:24] federico at galassi dot net

    Description:
    ------------
    When calling proc_open inside the body
    of a function, pipes generated don't survive
    function's lifespan. resource is still there
    but stream is closed.

    Reproduce code:
    ---------------
    function foobar() {
    $proc = proc_open(
    "/usr/bin/php",
    array(
    0 => array('pipe', 'r'),
    1 => array('pipe', 'w'),
    2 => array('pipe', 'w')
    ),
    $pipes
    );
    var_dump($pipes);
    return $pipes;
    }
    $should_be_pipes = foobar();
    var_dump($should_be_pipes);

    Expected result:
    ----------------
    array(3) {
    [0]=>
    resource(6) of type (stream)
    [1]=>
    resource(7) of type (stream)
    [2]=>
    resource(8) of type (stream)
    }
    array(3) {
    [0]=>
    resource(6) of type (stream)
    [1]=>
    resource(7) of type (stream)
    [2]=>
    resource(8) of type (stream)
    }

    Actual result:
    --------------
    array(3) {
    [0]=>
    resource(6) of type (stream)
    [1]=>
    resource(7) of type (stream)
    [2]=>
    resource(8) of type (stream)
    }
    array(3) {
    [0]=>
    resource(6) of type (Unknown)
    [1]=>
    resource(7) of type (Unknown)
    [2]=>
    resource(8) of type (Unknown)
    }


    ------------------------------------------------------------------------


    --
    Edit this bug report at [url]http://bugs.php.net/?id=39982&edit=1[/url]
    tony2001@php.net Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139