aboutsummaryrefslogtreecommitdiff
path: root/testcases
diff options
context:
space:
mode:
authorYang Xu <xuyang2018.jy@cn.fujitsu.com>2020-03-25 13:07:00 +0800
committerCyril Hrubis <chrubis@suse.cz>2020-05-05 16:54:51 +0200
commit15bb8857e6470a4326af23e63e596a30dbc426a8 (patch)
treea708be702a8a0e649e019849f24ee50244cce436 /testcases
parent6b6b56cf35dbcb518aa177a076f18006df677ee3 (diff)
openposix/twoptimers: handle signal correctly
Block this signal so that the default default disposition (program termination) does not kill the parent process before we can get the pending signal with sigwait(). Also remove the useless sleep in child that only slow downs the test. Signed-off-by: Yang Xu <xuyang2018.jy@cn.fujitsu.com> Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
Diffstat (limited to 'testcases')
-rw-r--r--testcases/open_posix_testsuite/functional/timers/timers/twoptimers.c30
1 files changed, 24 insertions, 6 deletions
diff --git a/testcases/open_posix_testsuite/functional/timers/timers/twoptimers.c b/testcases/open_posix_testsuite/functional/timers/timers/twoptimers.c
index 84bea3f0a..aa9a7f766 100644
--- a/testcases/open_posix_testsuite/functional/timers/timers/twoptimers.c
+++ b/testcases/open_posix_testsuite/functional/timers/timers/twoptimers.c
@@ -17,8 +17,7 @@
#include <unistd.h>
#include "posixtest.h"
-#define EXPIREDELTA 3
-#define LONGTIME 5
+#define EXPIREDELTA 2
#define CHILDPASS 1
@@ -51,6 +50,10 @@ int main(int argc, char *argv[])
return PTS_UNRESOLVED;
}
+ if (sigprocmask(SIG_BLOCK, &set, NULL) == -1) {
+ perror("sigprocmask() failed\n");
+ return PTS_UNRESOLVED;
+ }
ev.sigev_notify = SIGEV_SIGNAL;
ev.sigev_signo = SIGABRT;
if (timer_create(CLOCK_REALTIME, &ev, &tid) != 0) {
@@ -73,10 +76,14 @@ int main(int argc, char *argv[])
perror("sigwait() failed\n");
return PTS_UNRESOLVED;
}
- printf("Got it! Child\n");
- sleep(LONGTIME);
- return CHILDPASS;
+ if (sig == SIGABRT) {
+ printf("Got it! Child\n");
+ return CHILDPASS;
+ }
+
+ printf("Got another signal! Child\n");
+ return PTS_FAIL;
} else {
/*parent */
struct sigevent ev;
@@ -97,6 +104,11 @@ int main(int argc, char *argv[])
return PTS_UNRESOLVED;
}
+ if (sigprocmask(SIG_BLOCK, &set, NULL) == -1) {
+ perror("sigaprocmask() failed\n");
+ return PTS_UNRESOLVED;
+ }
+
ev.sigev_notify = SIGEV_SIGNAL;
ev.sigev_signo = SIGALRM;
if (timer_create(CLOCK_REALTIME, &ev, &tid) != 0) {
@@ -119,7 +131,13 @@ int main(int argc, char *argv[])
perror("sigwait() failed\n");
return PTS_UNRESOLVED;
}
- printf("Got it! Parent\n");
+
+ if (sig != SIGALRM) {
+ printf("Got another signal! Parent\n");
+ return PTS_FAIL;
+ }
+
+ printf("Got it! Parent\n");
if (wait(&i) == -1) {
perror("Error waiting for child to exit\n");