X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=src%2Fstdio%2F__stdio_write.c;h=cef7bbdc37238cbc8607a0e09e68f1551567d1e5;hb=31a55f233b313030a787240b76c06f2d08cde29f;hp=dd97cf68ac15f08a3c71fc6553418f39185539d4;hpb=58165923890865a6ac042fafce13f440ee986fd9;p=musl diff --git a/src/stdio/__stdio_write.c b/src/stdio/__stdio_write.c index dd97cf68..cef7bbdc 100644 --- a/src/stdio/__stdio_write.c +++ b/src/stdio/__stdio_write.c @@ -18,10 +18,15 @@ size_t __stdio_write(FILE *f, const unsigned char *buf, size_t len) int iovcnt = 2; ssize_t cnt; for (;;) { - pthread_cleanup_push(cleanup, f); - cnt = syscall_cp(SYS_writev, f->fd, iov, iovcnt); - pthread_cleanup_pop(0); + if (libc.main_thread) { + pthread_cleanup_push(cleanup, f); + cnt = syscall_cp(SYS_writev, f->fd, iov, iovcnt); + pthread_cleanup_pop(0); + } else { + cnt = syscall(SYS_writev, f->fd, iov, iovcnt); + } if (cnt == rem) { + f->wend = f->buf + f->buf_size; f->wpos = f->wbase = f->buf; return len; }