diff options
author | Karel Zak | 2015-07-01 15:35:17 +0200 |
---|---|---|
committer | Karel Zak | 2015-07-01 15:35:17 +0200 |
commit | 048811c97a97cdc574dc9307fb1bdd54e41d2a60 (patch) | |
tree | 8e5b5d2d6cf34e42e5102da9873479d6b6579c62 /sys-utils/swapon.c | |
parent | lib/strutils: make strmode() more generic (diff) | |
download | kernel-qcow2-util-linux-048811c97a97cdc574dc9307fb1bdd54e41d2a60.tar.gz kernel-qcow2-util-linux-048811c97a97cdc574dc9307fb1bdd54e41d2a60.tar.xz kernel-qcow2-util-linux-048811c97a97cdc574dc9307fb1bdd54e41d2a60.zip |
swapon: fix restart waitpid with errno == EINTR
Reported-by: Maks Naumov (https://github.com/karelzak/util-linux/pull/205)
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'sys-utils/swapon.c')
-rw-r--r-- | sys-utils/swapon.c | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/sys-utils/swapon.c b/sys-utils/swapon.c index 561b1a967..32a3107fd 100644 --- a/sys-utils/swapon.c +++ b/sys-utils/swapon.c @@ -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) |