#include "stdio_impl.h"
+#include <sys/uio.h>
#include <pthread.h>
static void cleanup(void *p)
};
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;