mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-06-27 14:58:30 +00:00
Make the Windows Console work better
The stdio reader thread now appears to be working recursively along cosmopolitan subprocesses. For example, it's now possible to launch vim.com from the unbourne.com bestline repl, thanks to hacks plus a bug fix to select() timeouts.
This commit is contained in:
parent
032b1f3449
commit
8bdaddd81d
68 changed files with 580 additions and 346 deletions
|
@ -7,6 +7,7 @@
|
|||
│ • http://creativecommons.org/publicdomain/zero/1.0/ │
|
||||
╚─────────────────────────────────────────────────────────────────*/
|
||||
#endif
|
||||
#include "libc/assert.h"
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/struct/sigaction.h"
|
||||
#include "libc/errno.h"
|
||||
|
@ -15,7 +16,9 @@
|
|||
#include "libc/sock/struct/pollfd.h"
|
||||
#include "libc/stdio/stdio.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/sysv/consts/f.h"
|
||||
#include "libc/sysv/consts/limits.h"
|
||||
#include "libc/sysv/consts/o.h"
|
||||
#include "libc/sysv/consts/poll.h"
|
||||
#include "libc/sysv/consts/sig.h"
|
||||
|
||||
|
@ -45,7 +48,7 @@ int main(int argc, char *argv[]) {
|
|||
// some programs are blocked on cpu rather than i/o
|
||||
// such programs shall rely on asynchronous signals
|
||||
printf("doing cpu task...\n");
|
||||
for (volatile int i = 0; i < INT_MAX / 20; ++i) {
|
||||
for (volatile int i = 0; i < INT_MAX / 5; ++i) {
|
||||
if (gotsig) {
|
||||
printf("\rgot ctrl+c asynchronously\n");
|
||||
exit(0);
|
||||
|
@ -55,7 +58,7 @@ int main(int argc, char *argv[]) {
|
|||
// posix guarantees atomic i/o if you use pipe_buf sized buffers
|
||||
// that way we don't need to worry about things like looping and
|
||||
// we can also be assured that multiple actors wont have tearing
|
||||
char buf[PIPE_BUF];
|
||||
char buf[4];
|
||||
|
||||
// read data from standard input
|
||||
//
|
||||
|
@ -107,5 +110,6 @@ int main(int argc, char *argv[]) {
|
|||
// operating system will send SIGPIPE if there's any problem
|
||||
// which kills the process by default
|
||||
write(1, buf, got);
|
||||
write(1, "\n", 1);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue