X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=src%2Fstdio%2F__stdio_write.c;h=e52e91ae0f5e0dddc40ca98137fc17fe2c99c15d;hb=8d3ee0575423edd203ee9e9f6b8ef1974ed5b1d9;hp=da45673f23bfd1cad6f3b52fea458f3143e9a874;hpb=b7a2761780c28cd0167ce4e51623e42298096708;p=musl diff --git a/src/stdio/__stdio_write.c b/src/stdio/__stdio_write.c index da45673f..e52e91ae 100644 --- a/src/stdio/__stdio_write.c +++ b/src/stdio/__stdio_write.c @@ -1,4 +1,5 @@ #include "stdio_impl.h" +#include #include static void cleanup(void *p) @@ -18,9 +19,13 @@ 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;