From: Karel Zak Date: Wed, 1 Jul 2015 13:35:17 +0000 (+0200) Subject: swapon: fix restart waitpid with errno == EINTR X-Git-Tag: v2.27-rc1~97 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=048811c97a97cdc574dc9307fb1bdd54e41d2a60;p=thirdparty%2Futil-linux.git swapon: fix restart waitpid with errno == EINTR Reported-by: Maks Naumov (https://github.com/karelzak/util-linux/pull/205) Signed-off-by: Karel Zak --- diff --git a/sys-utils/swapon.c b/sys-utils/swapon.c index 561b1a9671..32a3107fd6 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)