From: [EMAIL PROTECTED] Operating system: Linux 2.2.13-33 PHP version: 4.0.3pl1 PHP Bug Type: Scripting Engine problem Bug description: exec($cmd,$ret,$status) always return $status is -1 PHP scripts <? $cmd = "ls"; $ar = array(); exec($cmd, $ar, $atatus); echo $status; ?> $status is always -1 (accidential it is 0). May be PHP's source code file ext/standard/exec.c line 187's pclose(fp) returns -1. becose main/main.c line 598's signal(SIGCHLD,sigchild_handler) destory child prosess status. mey be fixed it to replase ext/standard/exec.c follows. add include #include <signal.h> add variable declaration void (*sig_hadler)(); add "signal handler for SIGCHLD set to SIG_DFL" at top of _Exec() sig_handler = signal (SIGCHLD, SIG_DFL); add "signal handler for SIGCHLD back to before" at before every return statments signal (SIGCHLD, sig_handler); This is patch. -----------------------------start---------------------- diff -uNr php-4.0.3pl1.orig/ext/standard/exec.c php-4.0.3pl1/ext/standard/exec.c --- php-4.0.3pl1.orig/ext/standard/exec.c Wed Sep 6 01:55:32 2000 +++ php-4.0.3pl1/ext/standard/exec.c Tue Jan 30 16:23:40 2001 @@ -30,6 +30,7 @@ #if HAVE_SYS_WAIT_H #include <sys/wait.h> #endif +#include <signal.h> /* * If type==0, only last line of output is returned (exec) @@ -46,11 +47,14 @@ int t, l, ret, output=1; int overflow_limit, lcmd, ldir; char *b, *c, *d=NULL; + void (*sig_handler)(); PLS_FETCH(); + sig_handler = signal (SIGCHLD, SIG_DFL); buf = (char*) emalloc(EXEC_INPUT_BUF); if (!buf) { php_error(E_WARNING, "Unable to emalloc %d bytes for exec buffer", EXEC_INPUT_BUF); + signal (SIGCHLD, sig_handler); return -1; } buflen = EXEC_INPUT_BUF; @@ -65,6 +69,7 @@ if (strstr(cmd, "..")) { php_error(E_WARNING, "No '..' components allowed in path"); efree(buf); + signal (SIGCHLD, sig_handler); return -1; } d = emalloc(l); @@ -95,6 +100,7 @@ php_error(E_WARNING, "Unable to fork [%s]", d); efree(d); efree(buf); + signal (SIGCHLD, sig_handler); return -1; } } else { /* not safe_mode */ @@ -106,6 +112,7 @@ if (!fp) { php_error(E_WARNING, "Unable to fork [%s]", cmd); efree(buf); + signal (SIGCHLD, sig_handler); return -1; } } @@ -127,6 +134,7 @@ if ( buf == NULL ) { php_error(E_WARNING, "Unable to erealloc %d bytes for exec buffer", buflen + EXEC_INPUT_BUF); + signal (SIGCHLD, sig_handler); return -1; } buflen += EXEC_INPUT_BUF; @@ -190,6 +198,7 @@ ret = WEXITSTATUS(ret); } #endif + signal (SIGCHLD, sig_handler); if (d) efree(d); efree(buf); -----------------------------end---------------------- pclose() function is also used in ext/standard/file.c mail.c ext/imap/php_imap.c. I do not know this influence. This is part of my phpinfo() outputs. Configure Command './configure' '--enable-sigchild' '--libdir=/var/tmp/php-root/usr/lib/php4' '--includedir=/usr/include' '--with-pgsql=shared' '--with-interbase' '--prefix=/var/tmp/php-root//usr' '--with-apxs=/usr/sbin/apxs' '--with-config-file-path=/etc/httpd' '--enable-safe-mode' '--disable-debug' '--with-zlib' '--with-gd' '--with-cpdflib' '--enable-debugger' '--enable-magic-quotes' '--enable-track-vars' '--enable-versioning' -- Edit Bug report at: http://bugs.php.net/?id=8992&edit=1 -- PHP Development Mailing List <http://www.php.net/> To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]