[systemd-devel] [not-for-applying PATCH] nsenter: do not self-suspend if child is suspended

Zbigniew Jędrzejewski-Szmek zbyszek at in.waw.pl
Sun Apr 21 07:50:19 PDT 2013


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



More information about the systemd-devel mailing list