mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-04-15 12:18:52 +00:00
Fix Windows stdin regression
The non-blocking standard input feature was broken by ec957491e
.
This commit is contained in:
parent
7e08a97cea
commit
b9eb656e41
4 changed files with 19 additions and 7 deletions
|
@ -135,8 +135,8 @@ dontasan dontubsan dontinstrument textwindows void WinMainStdin(void) {
|
||||||
NTTRACE("<stdin> CreateThread failed");
|
NTTRACE("<stdin> CreateThread failed");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
g_fds.stdin.thread = hStdin;
|
g_fds.stdin.handle = hStdin;
|
||||||
g_fds.stdin.handle = hThread;
|
g_fds.stdin.thread = hThread;
|
||||||
g_fds.stdin.reader = hReader;
|
g_fds.stdin.reader = hReader;
|
||||||
g_fds.stdin.writer = hWriter;
|
g_fds.stdin.writer = hWriter;
|
||||||
g_fds.stdin.inisem = hSemaphore;
|
g_fds.stdin.inisem = hSemaphore;
|
||||||
|
|
|
@ -330,7 +330,7 @@ privileged long kloghandle(void) {
|
||||||
kNtDuplicateSameAccess);
|
kNtDuplicateSameAccess);
|
||||||
} else if (n && n < 512) {
|
} else if (n && n < 512) {
|
||||||
hand = __imp_CreateFileW(
|
hand = __imp_CreateFileW(
|
||||||
path, kNtGenericWrite | kNtFileAppendData,
|
path, kNtFileAppendData,
|
||||||
kNtFileShareRead | kNtFileShareWrite | kNtFileShareDelete,
|
kNtFileShareRead | kNtFileShareWrite | kNtFileShareDelete,
|
||||||
&kNtIsInheritable, kNtOpenAlways, kNtFileAttributeNormal, 0);
|
&kNtIsInheritable, kNtOpenAlways, kNtFileAttributeNormal, 0);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -202,15 +202,15 @@ __msabi textwindows int64_t WinMain(int64_t hInstance, int64_t hPrevInstance,
|
||||||
kStartTsc = rdtsc();
|
kStartTsc = rdtsc();
|
||||||
__umask = 077;
|
__umask = 077;
|
||||||
__pid = __imp_GetCurrentProcessId();
|
__pid = __imp_GetCurrentProcessId();
|
||||||
DeduplicateStdioHandles();
|
|
||||||
if (_weaken(WinMainStdin)) {
|
|
||||||
_weaken(WinMainStdin)();
|
|
||||||
}
|
|
||||||
cmdline = MyCommandLine();
|
cmdline = MyCommandLine();
|
||||||
#ifdef SYSDEBUG
|
#ifdef SYSDEBUG
|
||||||
// sloppy flag-only check for early initialization
|
// sloppy flag-only check for early initialization
|
||||||
if (__strstr16(cmdline, u"--strace")) ++__strace;
|
if (__strstr16(cmdline, u"--strace")) ++__strace;
|
||||||
#endif
|
#endif
|
||||||
|
DeduplicateStdioHandles();
|
||||||
|
if (_weaken(WinMainStdin)) {
|
||||||
|
_weaken(WinMainStdin)();
|
||||||
|
}
|
||||||
if (_weaken(WinSockInit)) {
|
if (_weaken(WinSockInit)) {
|
||||||
_weaken(WinSockInit)();
|
_weaken(WinSockInit)();
|
||||||
}
|
}
|
||||||
|
|
|
@ -214,3 +214,15 @@ TEST(posixAdvisoryLocks, twoProcesses) {
|
||||||
ASSERT_SYS(0, 0, sigaction(SIGUSR1, &oldsa, 0));
|
ASSERT_SYS(0, 0, sigaction(SIGUSR1, &oldsa, 0));
|
||||||
ASSERT_SYS(0, 0, sigprocmask(SIG_SETMASK, &oldss, 0));
|
ASSERT_SYS(0, 0, sigprocmask(SIG_SETMASK, &oldss, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(fcntl, nonblock) {
|
||||||
|
int pfds[2];
|
||||||
|
char buf[8];
|
||||||
|
ASSERT_SYS(0, 0, pipe(pfds));
|
||||||
|
ASSERT_SYS(0, 0, fcntl(pfds[0], F_SETFL, O_RDONLY));
|
||||||
|
ASSERT_SYS(0, 0, fcntl(pfds[0], F_SETFL, O_RDONLY | O_NONBLOCK));
|
||||||
|
ASSERT_SYS(EAGAIN, -1, read(pfds[0], buf, 8));
|
||||||
|
ASSERT_SYS(0, 0, fcntl(pfds[0], F_SETFL, O_RDONLY));
|
||||||
|
ASSERT_SYS(0, 0, close(pfds[1]));
|
||||||
|
ASSERT_SYS(0, 0, close(pfds[0]));
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue