php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #29123 pclose() and proc_close() not returning proper exit status
Submitted: 2004-07-13 18:26 UTC Modified: 2004-07-16 01:32 UTC
Votes:17
Avg. Score:4.5 ± 0.8
Reproduced:14 of 14 (100.0%)
Same Version:3 (21.4%)
Same OS:4 (28.6%)
From: jtnix at maine dot rr dot com Assigned:
Status: Wont fix Package: Program Execution
PHP Version: 4.3.7 OS: Linux 2.4
Private report: No CVE-ID: None
 [2004-07-13 18:26 UTC] jtnix at maine dot rr dot com
Description:
------------
version 4.3.7 proc_close() and pclose() are not returning proper exit status codes from spawned processes.

Reproduce code:
---------------
$cmd = "rsync /pinky /brain"; 
## proc_ method
$setup = array( 1 => array("pipe", "w"));
$process = proc_open($cmd, $setup, $pipes);
if (is_resource($process)) {
    while(!feof($pipes[1])) {
        echo fgets($pipes[1], 1024);
    }
    fclose($pipes[1]);
    $rv = proc_close($process);
    echo ":: proc_close() method ::\n";
    echo "exit val: $rv\n\n";
}
## popen() method
$phnd = popen("$cmd", 'r');
while (!feof($phnd)) {
    $in = fread($phnd, 2048);
    echo $read;
}
$rv = pclose($phnd);
echo ":: pclose() ::\n";
echo "exit val: $rv\n\n";


Expected result:
----------------
## PHP 4.3.3 ##
link_stat /pinky : No such file or directory
rsync error: some files could not be transferred (code 23) at main.c(620)
:: proc_close() method ::
exit val: 23

link_stat /pinky : No such file or directory
rsync error: some files could not be transferred (code 23) at main.c(620)
:: pclose() ::
exit val: 23


Actual result:
--------------
## PHP 4.3.7 ##

link_stat /pinky : No such file or directory
rsync error: some files could not be transferred (code 23) at main.c(620)
:: proc_close() method ::
exit val: -1

link_stat /pinky : No such file or directory
rsync error: some files could not be transferred (code 23) at main.c(620)
:: pclose() ::
exit val: -1

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-07-13 19:10 UTC] wez@php.net
Are you using --enable-sigchild ?
If so, and you're not using Oracle, turn it off.
 [2004-07-13 19:37 UTC] jtnix at maine dot rr dot com
Yes we are using oracle and --enable-sigchild.

--enable-sigchild is not in use on the 4.3.3 install I tested.
 [2004-07-16 01:32 UTC] iliaa@php.net
When sigchild is used the return status from pclose and 
proc_close() cannot be retrieved. 
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 13:01:29 2024 UTC