Fix some additional Windows TTY issues

This commit is contained in:
Justine Tunney 2023-10-03 23:53:59 -07:00
parent f26a280cda
commit 1694edf85c
No known key found for this signature in database
GPG key ID: BE714B4575D6E328
12 changed files with 107 additions and 43 deletions

View file

@ -58,7 +58,16 @@ 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[4];
// 512 is the minimum permissible value for PIPE_BUF for all the
// platforms. when stdin is a terminal there are more guarantees
// about exactly how many bytes will be returned. in ICANON mode
// which is the default you can count on it returning one single
// line, including its \n (or VEOL, or VEOL2) per read. if using
// non-canonical raw mode, then a single logical keystroke shall
// be returned per read, so long as has VMIN characters or more,
// and the default VMIN is 1. you can also set VMIN w/ tcsetattr
// to 0 for a special kind of non-blocking mode.
char buf[512];
// read data from standard input
//
@ -109,7 +118,7 @@ int main(int argc, char *argv[]) {
// it's usually safe to ignore the return code of write. the
// operating system will send SIGPIPE if there's any problem
// which kills the process by default
write(1, "got: ", 5);
write(1, buf, got);
write(1, "\n", 1);
}
}