diff options
author | Wez Furlong <wez@php.net> | 2002-12-12 17:51:25 +0000 |
---|---|---|
committer | Wez Furlong <wez@php.net> | 2002-12-12 17:51:25 +0000 |
commit | c5d4e4b32105dbd74972ef042ca8c2023155974a (patch) | |
tree | e6c1d7a495cde9195a5fc371c8136267d74e921e /ext/standard/exec.c | |
parent | 2d8945247bd2f5cd089c3accef78b7b4e8194e57 (diff) | |
download | php-git-c5d4e4b32105dbd74972ef042ca8c2023155974a.tar.gz |
MFB: popen/pclose and proc_open/proc_close fixes.
Diffstat (limited to 'ext/standard/exec.c')
-rw-r--r-- | ext/standard/exec.c | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/ext/standard/exec.c b/ext/standard/exec.c index f83ca07f19..fd5076297b 100644 --- a/ext/standard/exec.c +++ b/ext/standard/exec.c @@ -118,6 +118,7 @@ int php_Exec(int type, char *cmd, pval *array, pval *return_value TSRMLS_DC) int overflow_limit, lcmd, ldir; char *b, *c, *d=NULL; php_stream *stream = NULL; + int pclose_return = 0; #if PHP_SIGCHILD void (*sig_handler)(); #endif @@ -283,13 +284,8 @@ int php_Exec(int type, char *cmd, pval *array, pval *return_value TSRMLS_DC) } } - FG(pclose_ret) = php_stream_close(stream); + pclose_return = php_stream_close(stream); -#if HAVE_SYS_WAIT_H - if (WIFEXITED(FG(pclose_ret))) { - FG(pclose_ret) = WEXITSTATUS(FG(pclose_ret)); - } -#endif #if PHP_SIGCHILD signal (SIGCHLD, sig_handler); #endif @@ -297,7 +293,7 @@ int php_Exec(int type, char *cmd, pval *array, pval *return_value TSRMLS_DC) efree(d); } efree(buf); - return FG(pclose_ret); + return pclose_return; } /* }}} */ @@ -586,8 +582,12 @@ static void proc_open_rsrc_dtor(zend_rsrc_list_entry *rsrc TSRMLS_DC) if (wait_pid == -1) FG(pclose_ret) = -1; - else + else { + if (WIFEXITED(wstatus)) + wstatus = WEXITSTATUS(wstatus); FG(pclose_ret) = wstatus; + } + # else FG(pclose_ret) = -1; # endif @@ -976,7 +976,7 @@ PHP_FUNCTION(proc_open) fp = fdopen(descriptors[i].parentend, mode_string); #endif if (fp) { - stream = php_stream_fopen_from_file(fp, mode_string); + stream = php_stream_fopen_from_pipe(fp, mode_string); if (stream) { zval *retfp; |