All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sukadev Bhattiprolu <sukadev-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org>
To: serue-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org
Cc: Containers
	<containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org>
Subject: [PATCH][cr-test] eclone-2 bug fix
Date: Mon, 3 May 2010 19:09:19 -0700	[thread overview]
Message-ID: <20100504020919.GB5098@us.ibm.com> (raw)


From: Sukadev Bhattiprolu <sukadev-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org>
Date: Mon, 3 May 2010 17:49:32 -0700
Subject: [PATCH 1/1] eclone-2 bug fix

When target-pid is in use, eclone() returns EBUSY, not EAGAIN.  The
test passes now because eclone() correctly fails, but the test case
can do a better job of checking the errno.

Signed-off-by: Sukadev Bhattiprolu <sukadev-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org>
---
 eclone/eclone-2.c |   49 ++++++++++++++++++++++++-------------------------
 1 files changed, 24 insertions(+), 25 deletions(-)

diff --git a/eclone/eclone-2.c b/eclone/eclone-2.c
index b825ac3..5550e43 100644
--- a/eclone/eclone-2.c
+++ b/eclone/eclone-2.c
@@ -64,14 +64,11 @@ static int do_eclone(int (*child_fn)(void *), void *child_arg,
 		fflush(stdout);
 	}
 
-	if (rc < 0 && errno == EAGAIN) {
-		printf("PASS: Unable to create a process with a pid that is "
-			"in use\n");
-		exit(0);
-	} else {
-		printf("ERROR: eclone(): rc %d, errno %d\n", rc, errno);
-		return rc;
-	}
+	if (rc < 0)
+		rc = -errno;
+
+	return rc;
+
 }
 
 int main()
@@ -90,27 +87,29 @@ int main()
 
 	pid = do_eclone(do_child, CHILD_ARG, flags, nr_pids, pids);
 
-	if (verbose) {
-		printf("[%d, %d]: Parent waiting for %d\n", getpid(),
-					gettid(), pid);
+	if (pid == -EBUSY) {
+		printf("PASS: Unable to create a process with a pid that is "
+			"in use\n");
+		return 0;
+	} else if (pid < 0) {
+		printf("ERROR: eclone(): errno %d\n", pid);
+		return 1;
 	}
 
+	printf("[%d, %d]: Parent waiting for %d\n", getpid(), gettid(), pid);
+
 	rc = waitpid(pid, &status, __WALL);
-	if (rc < 0) {
-		printf("ERROR: ");
-		verbose = 1;
-	}
 
-	if (verbose) {
-		printf("\twaitpid(): child %d, rc %d, error %d, status 0x%x\n",
-				getpid(), rc, errno, status);
-		if (rc >=0) {
-			if (WIFEXITED(status)) {
-				printf("\t EXITED, %d\n", WEXITSTATUS(status));
-			} else if (WIFSIGNALED(status)) {
-				printf("\t SIGNALED, %d\n", WTERMSIG(status));
-			}
+	printf("\twaitpid(): child %d, rc %d, error %d, status 0x%x\n",
+			getpid(), rc, errno, status);
+
+	if (rc >=0) {
+		if (WIFEXITED(status)) {
+			printf("\t EXITED, %d\n", WEXITSTATUS(status));
+		} else if (WIFSIGNALED(status)) {
+			printf("\t SIGNALED, %d\n", WTERMSIG(status));
 		}
 	}
-	return 0;
+
+	return 1;
 }
-- 
1.6.6.1

             reply	other threads:[~2010-05-04  2:09 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-05-04  2:09 Sukadev Bhattiprolu [this message]
     [not found] ` <20100504020919.GB5098-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2010-05-04 13:33   ` [PATCH][cr-test] eclone-2 bug fix Serge E. Hallyn
     [not found]     ` <20100504133328.GA10214-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2010-05-04 17:30       ` Sukadev Bhattiprolu
     [not found]         ` <20100504173051.GA11116-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2010-05-04 19:39           ` Serge E. Hallyn
     [not found]             ` <20100504193934.GA4781-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2010-05-05  2:04               ` Sukadev Bhattiprolu
     [not found]                 ` <20100505020404.GA19821-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2010-05-05 13:59                   ` Serge E. Hallyn

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20100504020919.GB5098@us.ibm.com \
    --to=sukadev-23vcf4htsmix0ybbhkvfkdbpr1lh4cv8@public.gmane.org \
    --cc=containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org \
    --cc=serue-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.