From: Karel Zak Date: Tue, 24 Nov 2015 16:44:38 +0000 (+0100) Subject: agetty: don't ignore netlink on select() X-Git-Tag: v2.28-rc1~266 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=5184d93630ded83770a90e6a663a2ca3f5f4bbf2;p=thirdparty%2Futil-linux.git agetty: don't ignore netlink on select() agetty uses NETLINK_ROUTE to be notified about network interface changes. Unfortunately, the code that monitor the netlink FD does not increment number of the monitored file descriptors when call select(2), so the netlink notifications are invisible for agetty. Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1278906 Signed-off-by: Karel Zak --- diff --git a/term-utils/agetty.c b/term-utils/agetty.c index a9c8785471..d2260e09f3 100644 --- a/term-utils/agetty.c +++ b/term-utils/agetty.c @@ -1637,16 +1637,22 @@ static int wait_for_term_input(int fd) } while (1) { + int nfds = fd; + FD_ZERO(&rfds); FD_SET(fd, &rfds); - if (inotify_fd >= 0) + if (inotify_fd >= 0) { FD_SET(inotify_fd, &rfds); - if (netlink_fd >= 0) + nfds = max(nfds, inotify_fd); + } + if (netlink_fd >= 0) { FD_SET(netlink_fd, &rfds); + nfds = max(nfds, netlink_fd); + } /* If waiting fails, just fall through, presumably reading input will fail */ - if (select(max(fd, inotify_fd) + 1, &rfds, NULL, NULL, NULL) < 0) + if (select(nfds + 1, &rfds, NULL, NULL, NULL) < 0) return 1; if (FD_ISSET(fd, &rfds)) {