From 5184d93630ded83770a90e6a663a2ca3f5f4bbf2 Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Tue, 24 Nov 2015 17:44:38 +0100 Subject: 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 --- term-utils/agetty.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'term-utils/agetty.c') diff --git a/term-utils/agetty.c b/term-utils/agetty.c index a9c878547..d2260e09f 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)) { -- cgit v1.2.3-55-g7522