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 | 309 | struct stat st; |
| 310 | + bool is_sock_or_fifo = false; | |
| 310 | 311 | if (fstat(p->fd, &st) == 0) { |
| 311 | 312 | if (S_ISDIR(st.st_mode)) { |
| 312 | 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 | 321 | fcntl(p->fd, F_SETFL, val); |
| 321 | 322 | #endif |
| 322 | 323 | } else { |
| 324 | +#ifndef __MINGW32__ | |
| 325 | + is_sock_or_fifo = S_ISSOCK(st.st_mode) || S_ISFIFO(st.st_mode); | |
| 326 | +#endif | |
| 323 | 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 | 345 | stream->get_size = get_size; |
| 342 | 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 | 349 | stream->streaming = true; |
| 346 | 350 | #if HAVE_COCOA |
| 347 | 351 | if (fcntl(p->fd, F_RDAHEAD, 0) < 0) { |