summaryrefslogtreecommitdiff
path: root/src/stdio/__stdio_read.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/stdio/__stdio_read.c')
-rw-r--r--src/stdio/__stdio_read.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/stdio/__stdio_read.c b/src/stdio/__stdio_read.c
index ee17a576..c99ca9a9 100644
--- a/src/stdio/__stdio_read.c
+++ b/src/stdio/__stdio_read.c
@@ -15,9 +15,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;