php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #41857 proc_close() sometimes returns 0 but most times returns -1
Submitted: 2007-06-29 20:52 UTC Modified: 2007-07-02 15:58 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: charpour at gnet dot gr Assigned:
Status: Not a bug Package: Program Execution
PHP Version: 5.2.3 OS: Debian 4.0 etch/Slackware 10.2.0
Private report: No CVE-ID: None
 [2007-06-29 20:52 UTC] charpour at gnet dot gr
Description:
------------
Sometimes proc_close() returns the expected value "0" but most times returns -1.

Configure command: 
 './configure' '--prefix=/usr/local/php5.2' '--with-mysql' '--with-mysql-sock' '--with-sqlite' '--enable-sqlite-utf8' '--with-zlib' '--with-zlib-dir' '--with-bz2' '--with-config-file-path=/usr/local/php5.2' '--enable-mbstring' '--enable-sigchild' '--enable-pcntl' '--enable-shmop' '--enable-sysvsem' '--enable-cli' '--disable-cgi'

Reproduce code:
---------------
<?php
$descriptorspec = array(
   0 => array("pipe", "r"),
   1 => array("pipe", "w"),
   2 => array("file", "/tmp/error-output.txt", "a")
);

$cwd = '/tmp';

$process = proc_open('ls -lap', $descriptorspec, $pipes, $cwd);

if (is_resource($process)) {

    fclose($pipes[0]);

    echo stream_get_contents($pipes[1]);
    fclose($pipes[1]);

    $return_value = proc_close($process);

    echo "command returned $return_value\n";
}
?>


Expected result:
----------------
command returned 0.

Actual result:
--------------
command returned 0. or command returned -1.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-06-29 21:37 UTC] charpour at gnet dot gr
Without these options in the configure command works fine (returns always 0) :
--enable-sigchild --enable-pcntl --enable-shmop --enable-sysvsem
 [2007-06-30 00:21 UTC] thespacefrog at hotmail dot com
I have the same problem with proc_close and I need the sigchild option to have the script run as a daemon. Is there any chance to fix this?:/

Thanks
 [2007-06-30 11:49 UTC] judas dot iscariote at gmail dot com
If you remove --enable-sigchild it will work. do not use that, is not needed anymore for nothing. ( IIRC was needed for old oracle extension that is no longer in use)

I only wonder why it has not been removed yet..
 [2007-07-01 13:37 UTC] sniper@php.net
According to Thies' commit comment about the --enable-sigchild option it is needed when using oracle libs >= 8.1
(see: cvs log -r1.132 configure.in)

Does it still count? And if it does, is this option just for the oracle stuff? If it is, why not move it into ext/oci8/config.m4 ? (and perhaps ext/pdo_oci/config.m4 needs it too..)
 [2007-07-02 08:00 UTC] tony2001@php.net
Jani, I've no idea what is --enable-sighild for and why it might be needed at all.
 [2007-07-02 15:58 UTC] iliaa@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

The --enable-sigchild is what's responsible for this option, having a 
sigchild handler in places prevents PHP from being able to properly 
detect status of a forked command. 
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 11:01:29 2024 UTC