From ef58f9b92ba4b57adee5f3b1582683111fb57526 Mon Sep 17 00:00:00 2001
From: rswindell <>
Date: Thu, 1 Nov 2001 18:19:52 +0000
Subject: [PATCH] Better handling of redirected input (using select).

---
 src/sbbs3/sbbscon.c | 48 ++++++++++++++++++++++-----------------------
 1 file changed, 23 insertions(+), 25 deletions(-)

diff --git a/src/sbbs3/sbbscon.c b/src/sbbs3/sbbscon.c
index 60c222eb22..87f570816f 100644
--- a/src/sbbs3/sbbscon.c
+++ b/src/sbbs3/sbbscon.c
@@ -397,34 +397,32 @@ int main(int argc, char** argv)
 	signal(SIGTERM, _sighandler_quit);
 #endif
 
-
-	while(!quit) {
-		if(!isatty(fileno(stdin))) {	/* redirected */
-			mswait(1);
-			continue;
-		}
-		ch=getch();
-		printf("%c\n",ch);
-		switch(ch) {
-			case 'q':
-				quit=TRUE;
-				break;
-			default:
-				printf("\nSynchronet BBS Console Version %s Help\n\n",SBBSCON_VERSION);
-				printf("q   = quit\n");
+	if(!isatty(fileno(stdin)))			/* redirected */
+		select(0,NULL,NULL,NULL,NULL);	/* so wait here until signaled */
+	else								/* interactive */
+		while(!quit) {
+			ch=getch();
+			printf("%c\n",ch);
+			switch(ch) {
+				case 'q':
+					quit=TRUE;
+					break;
+				default:
+					printf("\nSynchronet BBS Console Version %s Help\n\n",SBBSCON_VERSION);
+					printf("q   = quit\n");
 #if 0	/* to do */	
-				printf("n   = node list\n");
-				printf("w   = who's online\n");
-				printf("l#  = lock node #\n");
-				printf("d#  = down node #\n");
-				printf("i#  = interrupt node #\n");
-				printf("c#  = chat with node #\n");
-				printf("s#  = spy on node #\n");
+					printf("n   = node list\n");
+					printf("w   = who's online\n");
+					printf("l#  = lock node #\n");
+					printf("d#  = down node #\n");
+					printf("i#  = interrupt node #\n");
+					printf("c#  = chat with node #\n");
+					printf("s#  = spy on node #\n");
 #endif
-				lputs("");	/* redisplay prompt */
-				break;
+					lputs("");	/* redisplay prompt */
+					break;
+			}
 		}
-	}
 
 	bbs_terminate();
 	ftp_terminate();
-- 
GitLab