[prev in list] [next in list] [prev in thread] [next in thread] 

List:       util-linux-ng
Subject:    [not-for-applying PATCH] nsenter: do not self-suspend if child is suspended
From:       Zbigniew Jędrzejewski-Szmek <zbyszek () in ! waw ! pl>
Date:       2013-04-21 14:50:19
Message-ID: 1366555819-9208-1-git-send-email-zbyszek () in ! waw ! pl
[Download RAW message or body]

nsenter would kill(self, SIGSTOP) when the child was stopped,
making it possible to use 'suspend -f' in the child shell to
suspend both the shell and the parent nsenter process. Unfortunately
this interferes with other uses of SIGSTOP, since nsenter process
is not visible in the child PID namespace and can be only resumed
from outside.
---
 sys-utils/nsenter.c | 13 ++-----------
 1 file changed, 2 insertions(+), 11 deletions(-)

diff --git a/sys-utils/nsenter.c b/sys-utils/nsenter.c
index 106349c..5cef4bf 100644
--- a/sys-utils/nsenter.c
+++ b/sys-utils/nsenter.c
@@ -129,7 +129,6 @@ static void continue_as_child(void)
 {
 	pid_t child = fork();
 	int status;
-	pid_t ret;
 
 	if (child < 0)
 		err(EXIT_FAILURE, _("fork failed"));
@@ -138,16 +137,8 @@ static void continue_as_child(void)
 	if (child == 0)
 		return;
 
-	for (;;) {
-		ret = waitpid(child, &status, WUNTRACED);
-		if ((ret == child) && (WIFSTOPPED(status))) {
-			/* The child suspended so suspend us as well */
-			kill(getpid(), SIGSTOP);
-			kill(child, SIGCONT);
-		} else {
-			break;
-		}
-	}
+	waitpid(child, &status, 0);
+
 	/* Return the child's exit code if possible */
 	if (WIFEXITED(status)) {
 		exit(WEXITSTATUS(status));
-- 
1.8.2.562.g931e949

--
To unsubscribe from this list: send the line "unsubscribe util-linux" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic