#17538 [Opn]: proc_close() doesn't return exit value of process

From: Date: Thu, 01 Aug 2002 16:09:52 +0000
Subject: #17538 [Opn]: proc_close() doesn't return exit value of process
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-15751@lists.php.net to get a copy of this message
ID: 17538 Updated by: jflemer@php.net Reported By: kims@contrail.com.au Status: Open Bug Type: Filesystem function related Operating System: Debian GNU/Linux PHP Version: 4.0CVS-2002-05-30 Assigned To: wez New Comment: By the way, it also seems to make lots of zombies, which is probably related. Previous Comments: ------------------------------------------------------------------------ [2002-08-01 11:48:16] jflemer@php.net Do you think this could do it? Index: ext/standard/exec.c =================================================================== RCS file: /repository/php4/ext/standard/exec.c,v retrieving revision 1.77 diff -u -r1.77 exec.c --- ext/standard/exec.c 8 Jul 2002 12:52:22 -0000 1.77 +++ ext/standard/exec.c 1 Aug 2002 15:47:29 -0000 @@ -567,7 +567,7 @@ do { wait_pid = waitpid(child, &wstatus, 0); - } while (wait_pid == -1 && errno = EINTR); + } while (wait_pid == -1 && errno == EINTR); if (wait_pid == -1) FG(pclose_ret) = -1; ------------------------------------------------------------------------ [2002-08-01 11:35:42] jflemer@php.net Also w/ 4.3 SNAP 2002-07-03-1200 on RedHat 7.3. Config ops: --with-apxs --with-mysql=/usr/local/mysql --with-dom --with-xmlrpc --with-zlib-dir=/usr Always seems to return -1. ------------------------------------------------------------------------ [2002-05-31 00:16:58] kims@contrail.com.au For what it's worth, this problem also occurrs when php is compiled with --enable-sigchild. ------------------------------------------------------------------------ [2002-05-30 21:19:15] kims@contrail.com.au proc_close() seems to always return -1, instead of the exit value of the process it closed. I feel that this a bug in proc_close(). If proc_close() is returning -1 because of some sort of error or problem, then the online manual (http://www.php.net/proc_close) needs to specify what conditions make proc_close return -1. Here's a script that reproduces the problem. Thanks :) <? /* costants to use with the $pipes array */ define(BASH_STDIN, 0); define(BASH_STDOUT, 1); /* a random exit code, just to keep things interesting */ $bashexit = rand(100, 199); /* a shell script to write to bash's STDIN */ $shellscript .= " echo I am bash, and I will return an exit code of $bashexit exit $bashexit "; /* run bash, with pipes to/from stdin and stdout */ $bash = proc_open( "bash", array( 0 => array("pipe", "r"), 1 => array("pipe", "w"), 2 => array("file", "/tmp/bashstderr", "a") ), $pipes ); /* write the prepared shell script to bash's STDIN */ fwrite($pipes[BASH_STDIN], $shellscript); /* close pipe to bash's STDIN */ fclose($pipes[BASH_STDIN]); echo "bash's stdout:\n"; /* read and echo output from bash, one byte at a time */ while(!feof($pipes[BASH_STDOUT])) echo fread($pipes[BASH_STDOUT], 1); /* close pipe from bash's STDOUT */ fclose($pipes[BASH_STDOUT]); echo "\n"; $realexit = proc_close($bash); echo "bash's exit code: $realexit\n\n"; if ($realexit != $bashexit) echo "process exit code was $bashexit proc_close() returned $realexit!\n"; ?> ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=17538&edit=1

« previous php.bugs (#15751) next »