wez Thu Dec 12 12:44:49 2002 EDT
Modified files: (Branch: PHP_4_3)
/php4/ext/standard exec.c
/php4/main streams.c
Log:
Fix some issues with the return value from pclose and proc_close,
and bogus seek-on-pipe warnings when used with fpassthru.
Index: php4/ext/standard/exec.c
diff -u php4/ext/standard/exec.c:1.84.2.1 php4/ext/standard/exec.c:1.84.2.2
--- php4/ext/standard/exec.c:1.84.2.1 Thu Dec 5 16:09:18 2002
+++ php4/ext/standard/exec.c Thu Dec 12 12:44:48 2002
@@ -15,7 +15,7 @@
| Author: Rasmus Lerdorf |
+----------------------------------------------------------------------+
*/
-/* $Id: exec.c,v 1.84.2.1 2002/12/05 21:09:18 helly Exp $ */
+/* $Id: exec.c,v 1.84.2.2 2002/12/12 17:44:48 wez Exp $ */
#include <stdio.h>
#include "php.h"
@@ -118,6 +118,7 @@
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 @@
}
}
- 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 @@
efree(d);
}
efree(buf);
- return FG(pclose_ret);
+ return pclose_return;
}
/* }}} */
@@ -586,8 +582,12 @@
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 @@
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;
Index: php4/main/streams.c
diff -u php4/main/streams.c:1.125.2.19 php4/main/streams.c:1.125.2.20
--- php4/main/streams.c:1.125.2.19 Tue Dec 10 11:37:48 2002
+++ php4/main/streams.c Thu Dec 12 12:44:48 2002
@@ -20,7 +20,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: streams.c,v 1.125.2.19 2002/12/10 16:37:48 iliaa Exp $ */
+/* $Id: streams.c,v 1.125.2.20 2002/12/12 17:44:48 wez Exp $ */
#define _GNU_SOURCE
#include "php.h"
@@ -32,6 +32,9 @@
#ifdef HAVE_SYS_MMAN_H
#include <sys/mman.h>
#endif
+#if HAVE_SYS_WAIT_H
+#include <sys/wait.h>
+#endif
#include <stddef.h>
@@ -1317,6 +1320,7 @@
PHPAPI php_stream *_php_stream_fopen_from_pipe(FILE *file, const char *mode
STREAMS_DC TSRMLS_DC)
{
php_stdio_stream_data *self;
+ php_stream *stream;
self = emalloc_rel_orig(sizeof(*self));
self->file = file;
@@ -1325,7 +1329,9 @@
self->fd = fileno(file);
self->temp_file_name = NULL;
- return php_stream_alloc_rel(&php_stream_stdio_ops, self, 0, mode);
+ stream = php_stream_alloc_rel(&php_stream_stdio_ops, self, 0, mode);
+ stream->flags |= PHP_STREAM_FLAG_NO_SEEK;
+ return stream;
}
static size_t php_stdiop_write(php_stream *stream, const char *buf, size_t count
TSRMLS_DC)
@@ -1385,11 +1391,19 @@
php_stdio_stream_data *data = (php_stdio_stream_data*)stream->abstract;
assert(data != NULL);
-
+
if (close_handle) {
if (data->file) {
if (data->is_process_pipe) {
+ errno = 0;
ret = pclose(data->file);
+
+#if HAVE_SYS_WAIT_H
+ if (WIFEXITED(ret)) {
+ ret = WEXITSTATUS(ret);
+ }
+#endif
+
} else {
ret = fclose(data->file);
}
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php