aboutsummaryrefslogtreecommitdiff
path: root/std.c
diff options
context:
space:
mode:
authorMatthias-Christian Ott <ott@enolink.de>2008-06-14 23:24:12 +0200
committerMatthias-Christian Ott <ott@enolink.de>2008-06-14 23:24:12 +0200
commit7c63f47d3d0f7d01b6d6eae4ea6710dacebd927b (patch)
tree302c841b83e9be705defb0ab1af51ce1fa656c08 /std.c
parentbed0807e772102c97d8b576ecbaa550929cfdf36 (diff)
downloadst-7c63f47d3d0f7d01b6d6eae4ea6710dacebd927b.tar.gz
st-7c63f47d3d0f7d01b6d6eae4ea6710dacebd927b.tar.bz2
add select(2)-based i/o multiplexing
Diffstat (limited to 'std.c')
-rw-r--r--std.c26
1 files changed, 19 insertions, 7 deletions
diff --git a/std.c b/std.c
index 961ca55..fbabaa4 100644
--- a/std.c
+++ b/std.c
@@ -263,20 +263,32 @@ ungetch(int c) {
int
main(int argc, char *argv[]) {
+ fd_set rfds;
+ int r;
+
if(argc == 2 && !strcmp("-v", argv[1]))
eprint("std-"VERSION", © 2008 Matthias-Christian Ott\n");
else if(argc == 1)
eprint("usage: st [-v]\n");
getpty();
shell();
+ FD_ZERO(&rfds);
+ FD_SET(STDIN_FILENO, &rfds);
+ FD_SET(ptm, &rfds);
for(;;) {
- c = getch();
- switch(c) {
- case '\033':
- parseesc();
- break;
- default:
- putchar(c);
+ r = select(ptm + 1, &rfds, NULL, NULL, NULL);
+ if(r == -1)
+ eprintn("error, cannot select");
+ if(FD_ISSET(ptm, &rfds)) {
+ c = getch();
+ switch(c) {
+ case '\033':
+ parseesc();
+ break;
+ default:
+ putchar(c);
+ }
+ fflush(stdout);
}
}
return 0;