[LTP] [PATCH] rt_sigtimedwait01: fix probability of failure

Cui Bixuan cuibixuan@huawei.com
Wed Dec 28 13:14:45 CET 2016


If child[0] of test_masked_matching_rt() haven't had chance to
finish until we get to the sigwaitinfo() call, the case will fail.

So we should add waitpid() to make sure that both children are finished.

Signed-off-by: Cui Bixuan <cuibixuan@huawei.com>
---
 testcases/kernel/syscalls/utils/common_j_h.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/testcases/kernel/syscalls/utils/common_j_h.c b/testcases/kernel/syscalls/utils/common_j_h.c
index 43165ca..784ca04 100644
--- a/testcases/kernel/syscalls/utils/common_j_h.c
+++ b/testcases/kernel/syscalls/utils/common_j_h.c
@@ -119,6 +119,7 @@ static void sigterm_handler(int sig)
 pid_t create_sig_proc(unsigned long usec, int sig, unsigned count)
 {
 	pid_t pid, cpid;
+	int status;

 	pid = getpid();
 	WITH_SIGNALS_BLOCKED(if ((cpid = fork()) == 0) {
@@ -138,6 +139,8 @@ pid_t create_sig_proc(unsigned long usec, int sig, unsigned count)
 		EPRINTF("fork failed.\n");
 		return cpid;
 	default:
+		/* wait cpid finish */
+		waitpid(cpid, &status, 0);
 		return cpid;
 	}
 }
-- 
1.8.3.4




More information about the ltp mailing list