* [LTP] [PATCH] clone: wait until child completes
@ 2012-12-03 12:19 Jan Stancek
2012-12-04 7:20 ` Wanlong Gao
0 siblings, 1 reply; 2+ messages in thread
From: Jan Stancek @ 2012-12-03 12:19 UTC (permalink / raw)
To: ltp-list
If parent doesn't wait for child to finish,
ltp-pan detects these as 'orpahns' and will try
to kill them, which can result in TBROK messages:
http://article.gmane.org/gmane.linux.ltp/16993
Signed-off-by: Jan Stancek <jstancek@redhat.com>
---
testcases/kernel/syscalls/clone/clone01.c | 12 +++++++-----
testcases/kernel/syscalls/clone/clone03.c | 10 +++++++---
testcases/kernel/syscalls/clone/clone05.c | 10 +++++++---
testcases/kernel/syscalls/clone/clone06.c | 10 +++++++---
testcases/kernel/syscalls/clone/clone07.c | 6 ++++--
5 files changed, 32 insertions(+), 16 deletions(-)
diff --git a/testcases/kernel/syscalls/clone/clone01.c b/testcases/kernel/syscalls/clone/clone01.c
index dbf3315..4788802 100644
--- a/testcases/kernel/syscalls/clone/clone01.c
+++ b/testcases/kernel/syscalls/clone/clone01.c
@@ -105,17 +105,19 @@ int main(int ac, char **av)
Tst_count = 0;
TEST(ltp_clone(SIGCHLD, do_child, NULL, CHILD_STACK_SIZE, child_stack));
+ if (TEST_RETURN == -1)
+ tst_resm(TFAIL|TTERRNO, "clone failed");
-again:
child_pid = wait(&status);
+ if (child_pid == -1)
+ tst_brkm(TBROK|TERRNO, cleanup, "wait failed, status: %d",
+ status);
- /* check return code */
if (TEST_RETURN == child_pid)
tst_resm(TPASS, "clone returned %ld", TEST_RETURN);
- else if (TEST_RETURN == -1)
- tst_resm(TFAIL|TTERRNO, "clone failed for pid = %d", child_pid);
else
- goto again;
+ tst_resm(TFAIL, "clone returned %ld, wait returned %d",
+ TEST_RETURN, child_pid);
free(child_stack);
diff --git a/testcases/kernel/syscalls/clone/clone03.c b/testcases/kernel/syscalls/clone/clone03.c
index 24ee8e6..881aa6d 100644
--- a/testcases/kernel/syscalls/clone/clone03.c
+++ b/testcases/kernel/syscalls/clone/clone03.c
@@ -74,6 +74,7 @@
#include <errno.h>
#include <sched.h>
+#include <sys/wait.h>
#include "test.h"
#include "usctest.h"
@@ -95,7 +96,7 @@ int main(int ac, char **av)
char *msg;
void *child_stack; /* stack for child */
char buff[10];
- int child_pid;
+ int child_pid, status;
if ((msg = parse_opts(ac, av, NULL, NULL)) != NULL) {
tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
@@ -120,7 +121,7 @@ int main(int ac, char **av)
/*
* Call clone(2)
*/
- TEST(ltp_clone(0, child_fn, NULL, CHILD_STACK_SIZE,
+ TEST(ltp_clone(SIGCHLD, child_fn, NULL, CHILD_STACK_SIZE,
child_stack));
/* check return code */
@@ -152,6 +153,9 @@ int main(int ac, char **av)
tst_resm(TFAIL, "Test failed");
}
+ if ((wait(&status)) == -1)
+ tst_brkm(TBROK|TERRNO, cleanup,
+ "wait failed, status: %d", status);
}
free(child_stack);
@@ -165,7 +169,7 @@ int main(int ac, char **av)
void setup()
{
- tst_sig(NOFORK, DEF_HANDLER, cleanup);
+ tst_sig(FORK, DEF_HANDLER, cleanup);
TEST_PAUSE;
diff --git a/testcases/kernel/syscalls/clone/clone05.c b/testcases/kernel/syscalls/clone/clone05.c
index f557787..cb8a452 100644
--- a/testcases/kernel/syscalls/clone/clone05.c
+++ b/testcases/kernel/syscalls/clone/clone05.c
@@ -93,7 +93,7 @@ int TST_TOTAL = 1; /* Total number of test cases. */
int main(int ac, char **av)
{
- int lc;
+ int lc, status;
char *msg;
void *child_stack; /* stack for child */
@@ -114,7 +114,7 @@ int main(int ac, char **av)
/*
* Call clone(2)
*/
- TEST(ltp_clone(FLAG, child_fn, NULL, CHILD_STACK_SIZE,
+ TEST(ltp_clone(FLAG|SIGCHLD, child_fn, NULL, CHILD_STACK_SIZE,
child_stack));
/* check return code & parent_variable */
@@ -124,6 +124,10 @@ int main(int ac, char **av)
tst_resm(TFAIL, "Test Failed");
}
+ if ((wait(&status)) == -1)
+ tst_brkm(TBROK|TERRNO, cleanup,
+ "wait failed, status: %d", status);
+
/* Reset parent_variable */
parent_variable = 0;
}
@@ -139,7 +143,7 @@ int main(int ac, char **av)
void setup()
{
- tst_sig(NOFORK, DEF_HANDLER, cleanup);
+ tst_sig(FORK, DEF_HANDLER, cleanup);
TEST_PAUSE;
diff --git a/testcases/kernel/syscalls/clone/clone06.c b/testcases/kernel/syscalls/clone/clone06.c
index 6cb8b4d..2cfcd03 100644
--- a/testcases/kernel/syscalls/clone/clone06.c
+++ b/testcases/kernel/syscalls/clone/clone06.c
@@ -97,7 +97,7 @@ int TST_TOTAL = 1; /* Total number of test cases. */
int main(int ac, char **av)
{
- int lc;
+ int lc, status;
char *msg;
void *child_stack; /* stack for child */
char *parent_env;
@@ -123,7 +123,7 @@ int main(int ac, char **av)
/*
* Call clone(2)
*/
- TEST(ltp_clone(0, child_environ, NULL, CHILD_STACK_SIZE,
+ TEST(ltp_clone(SIGCHLD, child_environ, NULL, CHILD_STACK_SIZE,
child_stack));
/* check return code */
@@ -152,6 +152,10 @@ int main(int ac, char **av)
} else {
tst_resm(TFAIL, "Test Failed");
}
+
+ if ((wait(&status)) == -1)
+ tst_brkm(TBROK|TERRNO, cleanup,
+ "wait failed, status: %d", status);
}
free(child_stack);
@@ -164,7 +168,7 @@ int main(int ac, char **av)
void setup()
{
- tst_sig(NOFORK, DEF_HANDLER, cleanup);
+ tst_sig(FORK, DEF_HANDLER, cleanup);
TEST_PAUSE;
}
diff --git a/testcases/kernel/syscalls/clone/clone07.c b/testcases/kernel/syscalls/clone/clone07.c
index 3ad7fe7..c4df76d 100644
--- a/testcases/kernel/syscalls/clone/clone07.c
+++ b/testcases/kernel/syscalls/clone/clone07.c
@@ -98,7 +98,7 @@ static int fail = FALSE;
int main(int ac, char **av)
{
- int lc;
+ int lc, status;
char *msg;
void *child_stack; /* stack for child */
@@ -120,7 +120,9 @@ int main(int ac, char **av)
*/
child_pid = ltp_clone(SIGCHLD, do_child, NULL,
CHILD_STACK_SIZE, child_stack);
- wait(NULL);
+ if ((wait(&status)) == -1)
+ tst_brkm(TBROK|TERRNO, cleanup,
+ "wait failed, status: %d", status);
free(child_stack);
}
--
1.7.1
------------------------------------------------------------------------------
Keep yourself connected to Go Parallel:
BUILD Helping you discover the best ways to construct your parallel projects.
http://goparallel.sourceforge.net
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [LTP] [PATCH] clone: wait until child completes
2012-12-03 12:19 [LTP] [PATCH] clone: wait until child completes Jan Stancek
@ 2012-12-04 7:20 ` Wanlong Gao
0 siblings, 0 replies; 2+ messages in thread
From: Wanlong Gao @ 2012-12-04 7:20 UTC (permalink / raw)
To: Jan Stancek; +Cc: ltp-list
On 12/03/2012 08:19 PM, Jan Stancek wrote:
> If parent doesn't wait for child to finish,
> ltp-pan detects these as 'orpahns' and will try
> to kill them, which can result in TBROK messages:
> http://article.gmane.org/gmane.linux.ltp/16993
>
> Signed-off-by: Jan Stancek <jstancek@redhat.com>
Good work Jan, thank you, Applied,
Wanlong Gao
------------------------------------------------------------------------------
LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial
Remotely access PCs and mobile devices and provide instant support
Improve your efficiency, and focus on delivering more value-add services
Discover what IT Professionals Know. Rescue delivers
http://p.sf.net/sfu/logmein_12329d2d
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2012-12-04 7:22 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-12-03 12:19 [LTP] [PATCH] clone: wait until child completes Jan Stancek
2012-12-04 7:20 ` Wanlong Gao
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox