[lxc-devel] [PATCH] tests: daemonize in startone

Stéphane Graber stgraber at ubuntu.com
Thu Mar 13 14:49:00 UTC 2014


This should finally silence this test for good :)

Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
 src/tests/startone.c | 23 +++++------------------
 1 file changed, 5 insertions(+), 18 deletions(-)

diff --git a/src/tests/startone.c b/src/tests/startone.c
index b5056e1..9dd4ec3 100644
--- a/src/tests/startone.c
+++ b/src/tests/startone.c
@@ -163,24 +163,11 @@ int main(int argc, char *argv[])
 		fprintf(stderr, "%d: failed to get extra ref to container\n", __LINE__);
 		exit(1);
 	}
-	c->want_daemonize(c, false);
-	pid_t pid = fork();
-	if (pid < 0) {
-		fprintf(stderr, "%d: fork failed\n", __LINE__);
-		goto out;
-	}
-	if (pid == 0) {
-		close(0);
-		close(1);
-		close(2);
-		open("/dev/zero", O_RDONLY);
-		open("/dev/null", O_RDWR);
-		open("/dev/null", O_RDWR);
-		b = c->startl(c, 0, NULL);
-		if (!b)
-			fprintf(stderr, "%d: %s failed to start\n", __LINE__, c->name);
-		lxc_container_put(c);
-		exit(!b);
+
+	c->want_daemonize(c, true);
+	if (!c->startl(c, 0, NULL)) {
+		fprintf(stderr, "%d: %s failed to start\n", __LINE__, c->name);
+		exit(1);
 	}
 
 	sleep(3);
-- 
1.9.0



More information about the lxc-devel mailing list