public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP] [PATCH] Fix rt_sigtimedwait ordering test
@ 2011-02-07 14:28 Will Deacon
  2011-02-16 16:43 ` Will Deacon
       [not found] ` <9151393516569896904@unknownmsgid>
  0 siblings, 2 replies; 4+ messages in thread
From: Will Deacon @ 2011-02-07 14:28 UTC (permalink / raw)
  To: ltp-list

The rt_sigtimedwait test invokes test_masked_matching_rt, which
spawns two children who send consecutive RT signals to the parent.
The test then checks (via sigwaitinfo) that the RT signals are
delivered in the correct order: namely that the lower signal is taken
first.

This test can fail due to a race condition where the parent issues
the sigwaitinfo syscall before the first child has signalled the
parent but after the second child has (due to context switching).
This results in the signals being received in the reverse order.

This patch inserts waitpid syscalls to the parent thread so that the
sigwaitinfo call is only issued after the children have exited.

Signed-off-by: Will Deacon <will.deacon@arm.com>
---
 .../kernel/syscalls/sigwaitinfo/sigwaitinfo01.c    |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/testcases/kernel/syscalls/sigwaitinfo/sigwaitinfo01.c b/testcases/kernel/syscalls/sigwaitinfo/sigwaitinfo01.c
index c0e0241..439dfb3 100644
--- a/testcases/kernel/syscalls/sigwaitinfo/sigwaitinfo01.c
+++ b/testcases/kernel/syscalls/sigwaitinfo/sigwaitinfo01.c
@@ -232,6 +232,7 @@ void test_masked_matching_rt(swi_func sigwaitinfo, int signo)
 	sigset_t sigs, oldmask;
 	siginfo_t si;
 	pid_t child[2];
+	int status;
 
 	signo = SIGRTMIN+1;
 
@@ -250,6 +251,10 @@ void test_masked_matching_rt(swi_func sigwaitinfo, int signo)
 	child[0]=create_sig_proc(0, signo, 1);
 	child[1]=create_sig_proc(0, signo+1, 1);
 
+	/* Ensure that the signals have been sent */
+	waitpid(child[0], &status, 0);
+	waitpid(child[1], &status, 0);
+
 	TEST(sigwaitinfo(&sigs, &si, NULL));
 	REPORT_SUCCESS_COND(signo, 0, si.si_pid==child[0] && si.si_code==SI_USER && si.si_signo==signo, "Struct siginfo mismatch");
 
@@ -434,4 +439,4 @@ int main(int argc, char** argv)
 
 	cleanup();
 	tst_exit();
-}
\ No newline at end of file
+}
-- 
1.7.0.4



------------------------------------------------------------------------------
The modern datacenter depends on network connectivity to access resources
and provide services. The best practices for maximizing a physical server's
connectivity to a physical network are well understood - see how these
rules translate into the virtual world? 
http://p.sf.net/sfu/oracle-sfdevnlfb
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-02-25 10:54 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-02-07 14:28 [LTP] [PATCH] Fix rt_sigtimedwait ordering test Will Deacon
2011-02-16 16:43 ` Will Deacon
     [not found] ` <9151393516569896904@unknownmsgid>
2011-02-23  8:02   ` Garrett Cooper
2011-02-25 10:53     ` Will Deacon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox