]> granicus.if.org Git - php/commitdiff
Probable fix for #25575; STDIN/STDOUT/STDERR streams not registered
authorWez Furlong <wez@php.net>
Fri, 28 Nov 2003 22:48:31 +0000 (22:48 +0000)
committerWez Furlong <wez@php.net>
Fri, 28 Nov 2003 22:48:31 +0000 (22:48 +0000)
as network sockets when PHP run from x?inetd.

main/streams.c

index 62028f0a811425e420fd6a62c3b3c497cec12d6f..76647f1db6d837f295bbec951af1af9d97dd32f6 100755 (executable)
@@ -2016,6 +2016,16 @@ PHPAPI php_stream *_php_stream_fopen_from_fd(int fd, const char *mode, const cha
 {
        php_stdio_stream_data *self;
        php_stream *stream;
+#if defined(S_ISFIFO) || defined(S_ISSOCK)
+       struct stat sb;
+       int stat_ok;
+
+       stat_ok = fd >= 0 && fstat(fd, &sb) == 0;
+
+       if (stat_ok && S_ISSOCK(sb.st_mode)) {
+               return _php_stream_sock_open_from_socket(fd, persistent_id STREAMS_CC TSRMLS_CC);
+       }
+#endif
 
        self = pemalloc_rel_orig(sizeof(*self), persistent_id);
        memset(self, 0, sizeof(*self));
@@ -2027,9 +2037,8 @@ PHPAPI php_stream *_php_stream_fopen_from_fd(int fd, const char *mode, const cha
 
 #ifdef S_ISFIFO
        /* detect if this is a pipe */
-       if (self->fd >= 0) {
-               struct stat sb;
-               self->is_pipe = (fstat(self->fd, &sb) == 0 && S_ISFIFO(sb.st_mode)) ? 1 : 0;
+       if (stat_ok) {
+               self->is_pipe = S_ISFIFO(sb.st_mode) ? 1 : 0;
        }
 #elif defined(PHP_WIN32)
        {