if (stream == NULL) {
close(fd);
}
+#ifdef PHP_WIN32
+ {
+ zval *blocking_pipes = php_stream_context_get_option(context, "pipe", "blocking");
+ if (blocking_pipes) {
+ convert_to_long(blocking_pipes);
+ php_stream_set_option(stream, PHP_STREAM_OPTION_PIPE_BLOCKING, Z_LVAL_P(blocking_pipes), NULL);
+ }
+ }
+#endif
}
return stream;
#ifdef PHP_WIN32
int suppress_errors = 0;
int bypass_shell = 0;
+ int blocking_pipes = 0;
#endif
#if PHP_CAN_DO_PTS
php_file_descriptor_t dev_ptmx = -1; /* master */
bypass_shell = 1;
}
}
+
+ item = zend_hash_str_find(Z_ARRVAL_P(other_options), "blocking_pipes", sizeof("blocking_pipes") - 1);
+ if (item != NULL) {
+ if (Z_TYPE_P(item) == IS_TRUE || ((Z_TYPE_P(item) == IS_LONG) && Z_LVAL_P(item))) {
+ blocking_pipes = 1;
+ }
+ }
}
#endif
}
#ifdef PHP_WIN32
+ php_stream_set_option(stream, PHP_STREAM_OPTION_PIPE_BLOCKING, blocking_pipes, NULL);
descriptors[ndesc].childend = dup_fd_as_handle((int)fd);
if (descriptors[ndesc].childend == NULL) {
php_error_docref(NULL, E_WARNING, "unable to dup File-Handle for descriptor %d", nindex);
unsigned is_process_pipe:1; /* use pclose instead of fclose */
unsigned is_pipe:1; /* don't try and seek */
unsigned cached_fstat:1; /* sb is valid */
- unsigned _reserved:29;
+ unsigned is_pipe_blocking;
int lock_flag; /* stores the lock state */
zend_string *temp_name; /* if non-null, this is the path to a temporary file that
self->is_process_pipe = 0;
self->temp_name = NULL;
self->fd = fd;
+#ifndef PHP_WIN32
+ is_pipe_blocking = 0;
+#endif
return php_stream_alloc_rel(&php_stream_stdio_ops, self, persistent_id, mode);
}
self->is_process_pipe = 0;
self->temp_name = NULL;
self->fd = fileno(file);
+#ifndef PHP_WIN32
+ is_pipe_blocking = 0;
+#endif
return php_stream_alloc_rel(&php_stream_stdio_ops, self, 0, mode);
}
self->is_process_pipe = 1;
self->fd = fileno(file);
self->temp_name = NULL;
+#ifndef PHP_WIN32
+ is_pipe_blocking = 0;
+#endif
stream = php_stream_alloc_rel(&php_stream_stdio_ops, self, 0, mode);
stream->flags |= PHP_STREAM_FLAG_NO_SEEK;
#ifdef PHP_WIN32
php_stdio_stream_data *self = (php_stdio_stream_data*)stream->abstract;
- if (self->is_pipe || self->is_process_pipe) {
+ if ((self->is_pipe || self->is_process_pipe) && !self->is_pipe_blocking) {
HANDLE ph = (HANDLE)_get_osfhandle(data->fd);
int retry = 0;
DWORD avail_read = 0;
}
}
+#ifdef PHP_WIN32
+ case PHP_STREAM_OPTION_PIPE_BLOCKING:
+ data->is_pipe_blocking = value;
+ return PHP_STREAM_OPTION_RETURN_OK;
+#endif
+
default:
return PHP_STREAM_OPTION_RETURN_NOTIMPL;
}
return NULL;
}
}
+
+ if (options & STREAM_USE_BLOCKING_PIPE) {
+ php_stdio_stream_data *self = (php_stdio_stream_data*)ret->abstract;
+ self->is_pipe_blocking = 1;
+ }
#endif
return ret;