diff options
author | Karel Zak | 2015-11-24 17:44:38 +0100 |
---|---|---|
committer | Karel Zak | 2015-11-24 17:44:38 +0100 |
commit | 5184d93630ded83770a90e6a663a2ca3f5f4bbf2 (patch) | |
tree | 61fbd0c555a360888cbc1d4bc337a5bf15689139 /term-utils/agetty.c | |
parent | tests: update ZFS test (diff) | |
download | kernel-qcow2-util-linux-5184d93630ded83770a90e6a663a2ca3f5f4bbf2.tar.gz kernel-qcow2-util-linux-5184d93630ded83770a90e6a663a2ca3f5f4bbf2.tar.xz kernel-qcow2-util-linux-5184d93630ded83770a90e6a663a2ca3f5f4bbf2.zip |
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 <kzak@redhat.com>
Diffstat (limited to 'term-utils/agetty.c')
-rw-r--r-- | term-utils/agetty.c | 12 |
1 files changed, 9 insertions, 3 deletions
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)) { |