about summary refs log tree commit diff
path: root/Src/utils.c
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2003-02-05 11:56:55 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2003-02-05 11:56:55 +0000
commit590a26709a67abf13eeec66f161b0ec085637459 (patch)
treeea78dc37f3be5fc553682c81a876f27c25cd6d6e /Src/utils.c
parentf87232c120696b6e33b241e814d4e9b48efc13d7 (diff)
downloadzsh-590a26709a67abf13eeec66f161b0ec085637459.tar.gz
zsh-590a26709a67abf13eeec66f161b0ec085637459.tar.xz
zsh-590a26709a67abf13eeec66f161b0ec085637459.zip
18195: Timeouts for read builtin.
Diffstat (limited to 'Src/utils.c')
-rw-r--r--Src/utils.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/Src/utils.c b/Src/utils.c
index 8534a64cc..64a6a722e 100644
--- a/Src/utils.c
+++ b/Src/utils.c
@@ -1332,7 +1332,7 @@ setblock_stdin(void)
 
 /**/
 mod_export int
-read_poll(int fd, int *readchar, int polltty)
+read_poll(int fd, int *readchar, int polltty, zlong microseconds)
 {
     int ret = -1;
     long mode = -1;
@@ -1374,6 +1374,8 @@ read_poll(int fd, int *readchar, int polltty)
 	gettyinfo(&ti);
 	if ((polltty = ti.tio.c_cc[VMIN])) {
 	    ti.tio.c_cc[VMIN] = 0;
+	    /* termios timeout is 10ths of a second */
+	    ti.tio.c_cc[VTIME] = (int) (microseconds / (zlong)100000);
 	    settyinfo(&ti);
 	}
     }
@@ -1381,7 +1383,8 @@ read_poll(int fd, int *readchar, int polltty)
     polltty = 0;
 #endif
 #ifdef HAVE_SELECT
-    expire_tv.tv_sec = expire_tv.tv_usec = 0;
+    expire_tv.tv_sec = (int) (microseconds / (zlong)1000000);
+    expire_tv.tv_usec = microseconds % (zlong)1000000;
     FD_ZERO(&foofd);
     FD_SET(fd, &foofd);
     ret = select(fd+1, (SELECT_ARG_2_T) &foofd, NULL, NULL, &expire_tv);
@@ -1407,6 +1410,7 @@ read_poll(int fd, int *readchar, int polltty)
 #ifdef HAS_TIO
     if (polltty) {
 	ti.tio.c_cc[VMIN] = 1;
+	ti.tio.c_cc[VTIME] = 0;
 	settyinfo(&ti);
     }
 #endif