Improve Windows Console I/O

- Blocking read operations on the Windows Console can now EINTR
- Blocking read operations on Windows pipes now EINTR more reliably
- setitimer() will no longer be inherited across fork() on Windows
- It's now possible to use ECHO when the console is in raw mode
- The ECHOCTL flag now works correctly on the Windows Console
- The ICRNL flag now works correctly on the Windows Console
- pread() and pwrite() will now raise ESPIPE on Windows
- Opening /dev/tty on Windows is improved (untested)
- Overlapped I/O is now implemented in a better way
This commit is contained in:
Justine Tunney 2023-08-08 04:00:29 -07:00
parent decf216655
commit 33d280c8ba
No known key found for this signature in database
GPG key ID: BE714B4575D6E328
34 changed files with 580 additions and 376 deletions

View file

@ -474,12 +474,25 @@ void HandleClient(void) {
CHECK_NE(-1, events); // EINTR shouldn't be possible
if (events) {
if (fds[0].revents) {
if (!(fds[0].revents & POLLHUP)) {
WARNF("%s got unexpected input event from client %#x", exename,
fds[0].revents);
int received;
char buf[512];
INFOF("mbedtls_ssl_read");
received = mbedtls_ssl_read(&ezssl, buf, sizeof(buf));
if (!received) {
WARNF("%s client disconnected so killing worker %d", exename, child);
goto TerminateJob;
}
WARNF("%s client disconnected so killing worker %d", exename, child);
goto TerminateJob;
if (received > 0) {
WARNF("%s client sent %d unexpected bytes so killing job", exename,
received);
goto TerminateJob;
}
if (received != MBEDTLS_ERR_SSL_WANT_READ) {
WARNF("%s client ssl read failed with -0x%04x so killing job",
exename, -received);
goto TerminateJob;
}
INFOF("got spurious ssl data");
}
if (fds[1].revents) {
INFOF("read");