X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=src%2Fstdio%2F__stdio_read.c;h=05e56f923a8aef884a9a36bec983df605afabe32;hb=be81f51030d90de8d5eb0b65dbdab3032d5cae23;hp=ee17a576c5bb70c66c1def2d9d8f5537d7896059;hpb=58165923890865a6ac042fafce13f440ee986fd9;p=musl diff --git a/src/stdio/__stdio_read.c b/src/stdio/__stdio_read.c index ee17a576..05e56f92 100644 --- a/src/stdio/__stdio_read.c +++ b/src/stdio/__stdio_read.c @@ -1,4 +1,5 @@ #include "stdio_impl.h" +#include #include static void cleanup(void *p) @@ -15,9 +16,13 @@ size_t __stdio_read(FILE *f, unsigned char *buf, size_t len) }; ssize_t cnt; - pthread_cleanup_push(cleanup, f); - cnt = syscall_cp(SYS_readv, f->fd, iov, 2); - pthread_cleanup_pop(0); + if (libc.main_thread) { + pthread_cleanup_push(cleanup, f); + cnt = syscall_cp(SYS_readv, f->fd, iov, 2); + pthread_cleanup_pop(0); + } else { + cnt = syscall(SYS_readv, f->fd, iov, 2); + } if (cnt <= 0) { f->flags |= F_EOF ^ ((F_ERR^F_EOF) & cnt); f->rpos = f->rend = 0;