summary refs log tree commit diff
path: root/Src/Modules
diff options
context:
space:
mode:
authorClint Adams <clint@users.sourceforge.net>2001-09-27 15:36:41 +0000
committerClint Adams <clint@users.sourceforge.net>2001-09-27 15:36:41 +0000
commit8c05772007d403450624056cd24f8d53efa2da70 (patch)
tree9cdb8dd31808c57b67386996436903aea6cfb166 /Src/Modules
parent4f1d07bb8622f27135b90c5622a032a4d2fbdee3 (diff)
downloadzsh-8c05772007d403450624056cd24f8d53efa2da70.tar.gz
zsh-8c05772007d403450624056cd24f8d53efa2da70.tar.xz
zsh-8c05772007d403450624056cd24f8d53efa2da70.zip
15886: use select if poll is not available, or complain if neither are available
Diffstat (limited to 'Src/Modules')
-rw-r--r--Src/Modules/tcp.c27
1 files changed, 25 insertions, 2 deletions
diff --git a/Src/Modules/tcp.c b/Src/Modules/tcp.c
index cde2c2374..ae1b21912 100644
--- a/Src/Modules/tcp.c
+++ b/Src/Modules/tcp.c
@@ -538,6 +538,8 @@ bin_ztcp(char *nam, char **args, char *ops, int func)
 	}
 
 	if(test) {
+#if defined(HAVE_POLL) || defined(HAVE_SELECT)
+# ifdef HAVE_POLL
 	    struct pollfd pfd;
 	    int ret;
 
@@ -549,7 +551,29 @@ bin_ztcp(char *nam, char **args, char *ops, int func)
 		zwarnnam(nam, "poll error: %e", NULL, errno);
 		return 1;
 	    }
-
+# else
+	    fd_set rfds;
+	    struct timeval tv;
+	    int ret;
+	    
+	    FD_ZERO(&rfds);
+	    FD_SET(lfd, &rfds);
+	    tv.tv_sec = 0;
+	    tv.tv_usec = 0;
+	    
+	    if(ret = select(lfd+1, &rfds, NULL, NULL, &tv)) return 1;
+	    else if (ret == -1)
+	    {
+		zwarnnam(nam, "select error: %e", NULL, errno);
+		return 1;
+	    }
+	    
+# endif
+	    
+#else
+	    zwarnnam(nam, "not currently supported", NULL, 0);
+	    return 1;
+#endif
 	}
 	sess = zts_alloc(ZTCP_INBOUND);
 
@@ -572,7 +596,6 @@ bin_ztcp(char *nam, char **args, char *ops, int func)
 
 	if(verbose)
 	    fprintf(shout, "%d is on fd %d\n", ntohs(sess->peer.in.sin_port), sess->fd);
-
     }
     else
     {