mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-03-03 15:38:22 +00:00
Add better fix for Windows fork+strace TLS crashes
This commit is contained in:
parent
ad97775370
commit
6c60793f3a
1 changed files with 5 additions and 4 deletions
|
@ -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,
|
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);
|
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);
|
NTTRACE("%s(%ld, %p, %'zu) → %'zd% m", sf, h, buf, n, rc);
|
||||||
return rc != -1;
|
return rc != -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static dontinline textwindows bool WriteAll(int64_t h, void *buf, size_t n) {
|
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) {
|
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", true)) {
|
||||||
if (!ForkIo2(h, buf, n, ReadFile, "ReadFile")) {
|
|
||||||
AbortFork("ReadFile");
|
AbortFork("ReadFile");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue