commit 2003304
Devine Lu Linvega
·
2026-01-08 17:45:26 +0000 UTC
parent bbb187a
Removed duplicate fds
1 files changed,
+7,
-8
+7,
-8
1@@ -1296,27 +1296,26 @@ emu_run(void)
2 int has_input, has_eof, has_sent = 1;
3 char expirations[8], coninp[CONINBUFSIZE];
4 struct pollfd fds[3];
5- /* timer */
6 fds[0].fd = emu.fd_x11;
7 fds[1].fd = emu.fd_timer;
8 fds[2].fd = STDIN_FILENO;
9- fds[2].fd = STDIN_FILENO;
10 fds[0].events = fds[1].events = fds[2].events = POLLIN;
11- /* main loop */
12 while(!dev[0x0f]) {
13 if(poll(fds, 3, 1000) <= 0)
14 continue;
15- while(XPending(emu.dpy))
16- emu_event();
17+ if(fds[0].revents & POLLIN)
18+ while(XPending(emu.dpy))
19+ emu_event();
20 if(fds[1].revents & POLLIN) {
21- read(fds[1].fd, expirations, 8);
22+ read(emu.fd_timer, expirations, 8);
23 screen_update();
24 }
25 has_input = fds[2].revents & POLLIN;
26 has_eof = fds[2].revents & POLLHUP;
27+
28 if(has_input || has_eof) {
29- int i, n = read(fds[2].fd, coninp, CONINBUFSIZE - 1);
30- for(i = 0, coninp[n] = 0; i < n; i++)
31+ int i, n = read(STDIN_FILENO, coninp, CONINBUFSIZE - 1);
32+ for(i = 0; i < n; i++)
33 console_input(coninp[i], CONSOLE_STD), has_sent = 1;
34 if(n == 0 && has_sent)
35 console_input(0, CONSOLE_END), has_sent = 0;