Skip to content

Commit bdcd417

Browse files
committed
Avoid greedy reads on FIFOs
1 parent b317106 commit bdcd417

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

main/streams.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -1397,7 +1397,7 @@ PHPAPI php_stream *_php_stream_fopen_from_file(FILE *file, const char *mode STRE
13971397

13981398
if (stream) {
13991399
if (self->is_pipe) {
1400-
stream->flags |= PHP_STREAM_FLAG_NO_SEEK;
1400+
stream->flags |= PHP_STREAM_FLAG_NO_SEEK | PHP_STREAM_FLAG_AVOID_BLOCKING;
14011401
} else {
14021402
stream->position = ftell(file);
14031403
}
@@ -1419,7 +1419,7 @@ PHPAPI php_stream *_php_stream_fopen_from_pipe(FILE *file, const char *mode STRE
14191419
self->temp_file_name = NULL;
14201420

14211421
stream = php_stream_alloc_rel(&php_stream_stdio_ops, self, 0, mode);
1422-
stream->flags |= PHP_STREAM_FLAG_NO_SEEK;
1422+
stream->flags |= PHP_STREAM_FLAG_NO_SEEK | PHP_STREAM_FLAG_AVOID_BLOCKING;
14231423
return stream;
14241424
}
14251425

@@ -2041,7 +2041,7 @@ PHPAPI php_stream *_php_stream_fopen_from_fd(int fd, const char *mode, const cha
20412041

20422042
if (stream) {
20432043
if (self->is_pipe) {
2044-
stream->flags |= PHP_STREAM_FLAG_NO_SEEK;
2044+
stream->flags |= PHP_STREAM_FLAG_NO_SEEK | PHP_STREAM_FLAG_AVOID_BLOCKING;
20452045
} else {
20462046
stream->position = lseek(self->fd, 0, SEEK_CUR);
20472047
}

0 commit comments

Comments
 (0)