Skip to content

Commit

Permalink
properly set the pipe blocking option
Browse files Browse the repository at this point in the history
  • Loading branch information
weltling committed Jul 2, 2015
1 parent 1a5a4d5 commit d516a14
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
14 changes: 8 additions & 6 deletions ext/standard/php_fopen_wrapper.c
Original file line number Diff line number Diff line change
Expand Up @@ -400,17 +400,19 @@ php_stream * php_stream_url_wrap_php(php_stream_wrapper *wrapper, const char *pa
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);
if (stream && context) {
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;
}
/* }}} */
Expand Down
2 changes: 1 addition & 1 deletion ext/standard/proc_open.c
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,6 @@ PHP_FUNCTION(proc_open)
}

#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);
Expand Down Expand Up @@ -941,6 +940,7 @@ PHP_FUNCTION(proc_open)
#ifdef PHP_WIN32
stream = php_stream_fopen_from_fd(_open_osfhandle((zend_intptr_t)descriptors[i].parentend,
descriptors[i].mode_flags), mode_string, NULL);
php_stream_set_option(stream, PHP_STREAM_OPTION_PIPE_BLOCKING, blocking_pipes, NULL);
#else
stream = php_stream_fopen_from_fd(descriptors[i].parentend, mode_string, NULL);
# if defined(F_SETFD) && defined(FD_CLOEXEC)
Expand Down

0 comments on commit d516a14

Please sign in to comment.