]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
swapon: fix restart waitpid with errno == EINTR
authorKarel Zak <kzak@redhat.com>
Wed, 1 Jul 2015 13:35:17 +0000 (15:35 +0200)
committerKarel Zak <kzak@redhat.com>
Wed, 1 Jul 2015 13:35:17 +0000 (15:35 +0200)
Reported-by: Maks Naumov (https://github.com/karelzak/util-linux/pull/205)
Signed-off-by: Karel Zak <kzak@redhat.com>
sys-utils/swapon.c

index 561b1a9671eeb0bcfb37f99078cb677dbc45150a..32a3107fd697268b078e26fd3b392de4653cbd58 100644 (file)
@@ -317,14 +317,13 @@ static int swap_reinitialize(const char *device,
 
        default: /* parent */
                do {
-                       if ((ret = waitpid(pid, &status, 0)) < 0
-                                       && errno == EINTR)
-                               continue;
-                       else if (ret < 0) {
-                               warn(_("waitpid failed"));
-                               return -1;
-                       }
-               } while (0);
+                       ret = waitpid(pid, &status, 0);
+               } while (ret == -1 && errno == EINTR);
+
+               if (ret < 0) {
+                       warn(_("waitpid failed"));
+                       return -1;
+               }
 
                /* mkswap returns: 0=suss, 1=error */
                if (WIFEXITED(status) && WEXITSTATUS(status)==0)