sources/main.cpp

changeset 192
94c67ae846fc
parent 190
90bf9049e5eb
--- a/sources/main.cpp	Wed Jan 27 19:32:55 2021 +0200
+++ b/sources/main.cpp	Wed Jan 27 19:39:14 2021 +0200
@@ -72,35 +72,33 @@
 	if (argc == 3)
 		iface.connect (argv[1], argv[2]);
 
-	try
+	for (;;)
 	{
-		for (;;)
+		fd_set fdset;
+		timeval timeout;
+		timeout.tv_sec = 0;
+		timeout.tv_usec = 250000; // 0.25 seconds
+		FD_ZERO(&fdset);
+		FD_SET(0, &fdset);
+		const int fd = iface.getSession()->getSocket()->file_descriptor;
+		FD_SET(fd, &fdset);
+		::select(fd + 1, &fdset, nullptr, nullptr, &timeout);
+		bool shouldquit = false;
+		if (FD_ISSET(0, &fdset))
 		{
-			fd_set fdset;
-			int highest = 0;
-			timeval timeout;
-			timeout.tv_sec = 0;
-			timeout.tv_usec = 250000; // 0.25 seconds
-			FD_ZERO (&fdset);
-			FD_SET (0, &fdset);
-
-			int fd = iface.getSession()->getSocket()->file_descriptor;
-			highest = zfc::max (highest, fd);
-			FD_SET (fd, &fdset);
-
-			select (highest + 1, &fdset, nullptr, nullptr, &timeout);
-
-			if (FD_ISSET (0, &fdset))
-			{
-				// stdin is ready, what's incoming?
-				iface.handleInput();
-			}
-
+			// stdin is ready, what's incoming?
+			iface.handleInput(&shouldquit);
+		}
+		if (shouldquit)
+		{
+			break;
+		}
+		else
+		{
 			iface.getSession()->tick();
 			iface.render();
 		}
 	}
-	catch (const zfc::Exitception&) {}
 
 	iface.getSession()->disconnect();
 	return EXIT_SUCCESS;

mercurial