Don't preempt WIN32 libraries

This change refactors our POSIX signals emulation for Windows so that it
performs some additional safety checks before calling SetThreadContext()
which needs to be locked and must never ever interrupt Microsoft's code.
Kudos to the the Go developers for figuring out how to do this properly.
This commit is contained in:
Justine Tunney 2023-10-13 13:56:14 -07:00
parent d1a283a588
commit aca2261cda
No known key found for this signature in database
GPG key ID: BE714B4575D6E328
5 changed files with 61 additions and 30 deletions

View file

@ -193,8 +193,9 @@ sys_readwrite_nt(int fd, void *data, size_t size, ssize_t offset,
// check and see if it was pthread_cancel() which committed the deed
// in which case _check_cancel() can acknowledge the cancelation now
// it's also fine to do nothing here; punt to next cancelation point
if (GetLastError() == kNtErrorOperationAborted && _check_cancel() == -1) {
return ecanceled();
if (GetLastError() == kNtErrorOperationAborted) {
if (_check_cancel() == -1) return ecanceled();
if (!eintered && _check_signal(false)) return eintr();
}
// if we chose to process a pending signal earlier then we preserve