tom@ssd.csd.harris.com (Tom Horsley) (04/12/90)
Here is a patch to ephem version 4.13 that uses select() to check for a
pending keystroke. On my system select() seems to work better than either
of the two alternatives that are already built in.
*** io.c.orig Thu Apr 12 07:29:36 1990
--- io.c Thu Apr 12 07:30:13 1990
***************
*** 21,26 ****
--- 21,27 ----
*/
#define UNIX
+ #define USE_SELECT
/* #define USE_NDELAY */
/* #define TURBO_C */
/* #define USE_ANSISYS */
***************
*** 29,34 ****
--- 30,38 ----
#include "screen.h"
#ifdef UNIX
+ #ifdef USE_SELECT
+ #include <sys/time.h>
+ #endif
#include <sgtty.h>
#include <signal.h>
#ifdef USE_NDELAY
***************
*** 81,90 ****
--- 85,104 ----
sav_char = 0;
return (sav_char ? 0 : -1);
#else
+ #ifdef USE_SELECT
+ struct timeval timeout;
+ int readfs = 1<<0;
+ int nfound;
+
+ memset((char *)&timeout, 0, sizeof(struct timeval));
+ nfound = select(1, &readfs, 0, 0, &timeout);
+ return ((nfound > 0) ? 0 : -1);
+ #else
long n;
if (!ttysetup) setuptty();
ioctl (0, FIONREAD, &n);
return (n > 0 ? 0 : -1);
+ #endif
#endif
}
--
=====================================================================
domain: tahorsley@ssd.csd.harris.com USMail: Tom Horsley
uucp: ...!novavax!hcx1!tahorsley 511 Kingbird Circle
or ...!uunet!hcx1!tahorsley Delray Beach, FL 33444
======================== Aging: Just say no! ========================