mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-07 03:38:31 +00:00
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:
parent
decf216655
commit
33d280c8ba
34 changed files with 580 additions and 376 deletions
|
@ -18,7 +18,7 @@
|
|||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/calls/sig.internal.h"
|
||||
#include "libc/calls/struct/itimerval.h"
|
||||
#include "libc/calls/struct/timeval.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/sysv/consts/itimer.h"
|
||||
#include "libc/sysv/consts/sicode.h"
|
||||
#include "libc/sysv/consts/sig.h"
|
||||
|
@ -43,21 +43,33 @@ textwindows void _check_sigalrm(void) {
|
|||
__sig_add(0, SIGALRM, SI_TIMER);
|
||||
}
|
||||
|
||||
textwindows void sys_setitimer_nt_reset(void) {
|
||||
// this function is called by fork(), because
|
||||
// timers aren't inherited by forked subprocesses
|
||||
bzero(&g_setitimer, sizeof(g_setitimer));
|
||||
}
|
||||
|
||||
textwindows int sys_setitimer_nt(int which, const struct itimerval *neu,
|
||||
struct itimerval *old) {
|
||||
struct itimerval config;
|
||||
if (which != ITIMER_REAL || (neu && (!timeval_isvalid(neu->it_value) ||
|
||||
!timeval_isvalid(neu->it_interval)))) {
|
||||
return einval();
|
||||
}
|
||||
if (neu) {
|
||||
// POSIX defines setitimer() with the restrict keyword but let's
|
||||
// accommodate the usage setitimer(ITIMER_REAL, &it, &it) anyway
|
||||
config = *neu;
|
||||
}
|
||||
if (old) {
|
||||
old->it_interval = g_setitimer.it_interval;
|
||||
old->it_value = timeval_subz(g_setitimer.it_value, timeval_real());
|
||||
}
|
||||
if (neu) {
|
||||
g_setitimer.it_interval = neu->it_interval;
|
||||
g_setitimer.it_value = timeval_iszero(neu->it_value)
|
||||
? timeval_zero
|
||||
: timeval_add(timeval_real(), neu->it_value);
|
||||
if (!timeval_iszero(config.it_value)) {
|
||||
config.it_value = timeval_add(config.it_value, timeval_real());
|
||||
}
|
||||
g_setitimer = config;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue