]> git.ipfire.org Git - thirdparty/mdadm.git/blobdiff - mdstat.c
Improve partition table code.
[thirdparty/mdadm.git] / mdstat.c
index 4d2f473eb09a5b4714dda91fad6c222609c866b2..4a9f370060f36839792dfcd708bf3a23fed72c49 100644 (file)
--- a/mdstat.c
+++ b/mdstat.c
@@ -269,12 +269,13 @@ void mdstat_wait(int seconds)
 void mdstat_wait_fd(int fd, const sigset_t *sigmask)
 {
        fd_set fds, rfds;
-       int maxfd = fd;
+       int maxfd = 0;
 
        FD_ZERO(&fds);
        FD_ZERO(&rfds);
        if (mdstat_fd >= 0)
                FD_SET(mdstat_fd, &fds);
+
        if (fd >= 0) {
                struct stat stb;
                fstat(fd, &stb);
@@ -286,6 +287,10 @@ void mdstat_wait_fd(int fd, const sigset_t *sigmask)
                        FD_SET(fd, &fds);
                else
                        FD_SET(fd, &rfds);
+
+               if (fd > maxfd)
+                       maxfd = fd;
+
        }
        if (mdstat_fd > maxfd)
                maxfd = mdstat_fd;