From: Roy Marples Date: Wed, 7 May 2008 09:39:17 +0000 (+0000) Subject: dhcpcd doesn't really care about script exist status or if it was signalled, so save... X-Git-Tag: v4.0.2~432 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c3799faefb6200a29d7e875ec70418b523de152b;p=thirdparty%2Fdhcpcd.git dhcpcd doesn't really care about script exist status or if it was signalled, so save a few more bytes. --- diff --git a/configure.c b/configure.c index 5c1e50a2..1551f874 100644 --- a/configure.c +++ b/configure.c @@ -52,7 +52,6 @@ exec_script(const char *script, const char *iface, const char *reason, char *const argv[2] = { (char *)script, NULL }; int ret = 0; pid_t pid; - pid_t wpid; int status = 0; sigset_t full; sigset_t old; @@ -100,19 +99,15 @@ exec_script(const char *script, const char *iface, const char *reason, sigprocmask(SIG_SETMASK, &old, NULL); /* Wait for the script to finish */ - do { - wpid = waitpid(pid, &status, 0); - if (wpid < 1) + while (waitpid(pid, &status, 0) == -1) { + if (errno != EINTR) { logger(LOG_ERR, "waitpid: %s", strerror(errno)); - } while (!WIFEXITED(status) && !WIFSIGNALED(status)); + status = -1; + break; + } + } - if (WIFSIGNALED(status)) - logger(LOG_ERR, "script signaled"); - if (WIFEXITED(status)) - ret = WEXITSTATUS(status); - else - ret = -1; - return ret; + return status; } static struct rt *