diff --git a/libc/runtime/fork-nt.c b/libc/runtime/fork-nt.c index bdc6e5cc1..0e814e721 100644 --- a/libc/runtime/fork-nt.c +++ b/libc/runtime/fork-nt.c @@ -87,19 +87,20 @@ static inline textwindows ssize_t ForkIo(int64_t h, char *p, size_t n, } static dontinline textwindows bool ForkIo2(int64_t h, void *buf, size_t n, - bool32 (*fn)(), const char *sf) { + bool32 (*fn)(), const char *sf, + bool ischild) { ssize_t rc = ForkIo(h, buf, n, fn); + if (ischild) __tls_enabled = false; // prevent tls crash in kprintf NTTRACE("%s(%ld, %p, %'zu) → %'zd% m", sf, h, buf, n, rc); return rc != -1; } static dontinline textwindows bool WriteAll(int64_t h, void *buf, size_t n) { - return ForkIo2(h, buf, n, WriteFile, "WriteFile"); + return ForkIo2(h, buf, n, WriteFile, "WriteFile", false); } static textwindows dontinline void ReadOrDie(int64_t h, void *buf, size_t n) { - __tls_enabled = false; // prevent tls crash in kprintf - if (!ForkIo2(h, buf, n, ReadFile, "ReadFile")) { + if (!ForkIo2(h, buf, n, ReadFile, "ReadFile", true)) { AbortFork("ReadFile"); } }