]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
agetty: don't ignore netlink on select()
authorKarel Zak <kzak@redhat.com>
Tue, 24 Nov 2015 16:44:38 +0000 (17:44 +0100)
committerKarel Zak <kzak@redhat.com>
Tue, 24 Nov 2015 16:44:38 +0000 (17:44 +0100)
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 <kzak@redhat.com>
term-utils/agetty.c

index a9c87854711bcfad07aaa3961c287f626c7d87f6..d2260e09f3abd3d34a441932f5ef2eb53df5fcad 100644 (file)
@@ -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)) {