From 619b0b4f37dbf05f8e30e15b839ed17ab1a21f5b Mon Sep 17 00:00:00 2001 From: Roy Marples Date: Tue, 6 May 2008 21:53:21 +0000 Subject: [PATCH] Fix the EINTR check for waitpid, Gentoo #219929. --- src/rc/rc-plugin.c | 27 +++++++++++++++++---------- src/rc/rc.c | 7 ------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/rc/rc-plugin.c b/src/rc/rc-plugin.c index 8599af6f..55112f4a 100644 --- a/src/rc/rc-plugin.c +++ b/src/rc/rc-plugin.c @@ -120,18 +120,25 @@ void rc_plugin_load(void) int rc_waitpid(pid_t pid) { - int status = 0; + int status; pid_t savedpid = pid; - int retval = EXIT_FAILURE; - do { - pid = waitpid(savedpid, &status, 0); - if (pid == -1 && errno != EINTR) - return EXIT_FAILURE; - } while (!WIFEXITED(status) && !WIFSIGNALED(status)); - if (pid == savedpid) - retval = WIFEXITED(status) ? WEXITSTATUS(status) : EXIT_FAILURE; - return retval; +loop: + pid = waitpid(savedpid, &status, 0); + if (pid == -1) { + /* Our signal hander should take appropriate action. */ + if (errno == EINTR) + goto loop; + return EXIT_FAILURE; + } + + if (pid == savedpid) { + if (WIFEXITED(status)) + return WEXITSTATUS(status); + return EXIT_FAILURE; + } + + return EXIT_SUCCESS; } void rc_plugin_run(RC_HOOK hook, const char *value) diff --git a/src/rc/rc.c b/src/rc/rc.c index c1bc97e8..d5e9f34c 100644 --- a/src/rc/rc.c +++ b/src/rc/rc.c @@ -635,13 +635,6 @@ static void do_newlevel(const char *newlevel) { /* OK, we're either in runlevel 1 or single user mode */ - /* We don't want to trap SIGWINCH here as when a framebuffer - * driver is loaded by udev and we start using it then we - * race for some reason with the below scripts. - * This is fine as we only really need SIGWINCH for tidy - * output when using the logger. */ - signal_setup(SIGWINCH, SIG_DFL); - /* exec init-early.sh if it exists * This should just setup the console to use the correct * font. Maybe it should setup the keyboard too? */