This is useful e.g. when the caller dup2's a socket into stdin, or passes a socket/pipe as /dev/fd/{fd}, because it is impossible to seek on sockets and pipes.
Unified · Split
| @@ -307,6 +307,7 @@ static int open_f(stream_t *stream, const struct stream_open_args *args) · 306 unmodified lines | |||
| 307 | } | 307 | } |
| 308 | 308 | ||
| 309 | struct stat st; | 309 | struct stat st; |
| 310 | bool is_sock_or_fifo = false; | ||
| 310 | if (fstat(p->fd, &st) == 0) { | 311 | if (fstat(p->fd, &st) == 0) { |
| 311 | if (S_ISDIR(st.st_mode)) { | 312 | if (S_ISDIR(st.st_mode)) { |
| 312 | stream->is_directory = true; | 313 | stream->is_directory = true; |
| @@ -320,6 +321,9 @@ static int open_f(stream_t *stream, const struct stream_open_args *args) · 7 unmodified lines | |||
| 320 | fcntl(p->fd, F_SETFL, val); | 321 | fcntl(p->fd, F_SETFL, val); |
| 321 | #endif | 322 | #endif |
| 322 | } else { | 323 | } else { |
| 324 | #ifndef __MINGW32__ | ||
| 325 | is_sock_or_fifo = S_ISSOCK(st.st_mode) || S_ISFIFO(st.st_mode); | ||
| 326 | #endif | ||
| 323 | p->use_poll = true; | 327 | p->use_poll = true; |
| 324 | } | 328 | } |
| 325 | } | 329 | } |
| @@ -341,7 +345,7 @@ static int open_f(stream_t *stream, const struct stream_open_args *args) · 15 unmodified lines | |||
| 341 | stream->get_size = get_size; | 345 | stream->get_size = get_size; |
| 342 | stream->close = s_close; | 346 | stream->close = s_close; |
| 343 | 347 | ||
| 344 | if (check_stream_network(p->fd)) { | 348 | if (is_sock_or_fifo || check_stream_network(p->fd)) { |
| 345 | stream->streaming = true; | 349 | stream->streaming = true; |
| 346 | #if HAVE_COCOA | 350 | #if HAVE_COCOA |
| 347 | if (fcntl(p->fd, F_RDAHEAD, 0) < 0) { | 351 | if (fcntl(p->fd, F_RDAHEAD, 0) < 0) { |