mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-07 19:58:30 +00:00
Make improvements
- Improved async signal safety of read() particularly for longjmp() - Started adding cancel cleanup handlers for locks / etc on Windows - Make /dev/tty work better particularly for uses like `foo | less` - Eagerly read console input into a linked list, so poll can signal - Fix some libc definitional bugs, which configure scripts detected
This commit is contained in:
parent
d6c2830850
commit
0c5dd7b342
85 changed files with 1062 additions and 671 deletions
|
@ -67,30 +67,7 @@ static dontinline textwindows int sys_tcflush_nt(int fd, int queue) {
|
|||
if (queue == TCOFLUSH) {
|
||||
return 0; // windows console output is never buffered
|
||||
}
|
||||
FlushConsoleInputBuffer(hConin);
|
||||
int rc = 0;
|
||||
int e = errno;
|
||||
int oldflags = g_fds.p[fd].flags;
|
||||
g_fds.p[fd].flags |= O_NONBLOCK;
|
||||
for (;;) {
|
||||
char buf[512];
|
||||
ssize_t got = sys_read_nt_impl(fd, buf, 512, -1);
|
||||
if (!got) {
|
||||
break;
|
||||
} else if (got == -1) {
|
||||
if (errno == EAGAIN) {
|
||||
errno = e;
|
||||
} else if (errno == EINTR) {
|
||||
errno = e;
|
||||
continue;
|
||||
} else {
|
||||
rc = -1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
g_fds.p[fd].flags = oldflags;
|
||||
return rc;
|
||||
return FlushConsoleInputBytes(hConin);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue