int main(int ac, char **av) { int signal, flag; int lc; char *msg; if ((msg = parse_opts(ac, av, NULL, NULL)) != NULL) { tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg); } setup(); for (lc = 0; TEST_LOOPING(lc); ++lc) { Tst_count = 0; for (testno = 0; testno < TST_TOTAL; ++testno) { for (signal = SIGRTMIN; signal <= (SIGRTMAX ); signal++) {//signal for 34 to 65 #ifdef __x86_64__ sig_initial(signal); #endif for (flag = 0; flag < (sizeof(test_flags) / sizeof(test_flags[0])); flag++) { TEST(set_handler(signal, 0, test_flags[flag])); if (TEST_RETURN == 0) { tst_resm(TINFO,"signal: %d ", signal); tst_resm(TPASS, "rt_sigaction call succeeded: result = %ld ",TEST_RETURN ); tst_resm(TINFO, "sa.sa_flags = %s ",test_flags_list[flag]); kill(getpid(),signal); } else { tst_resm(TFAIL | TTERRNO, "rt_sigaction call " "failed"); } } } } } cleanup(); tst_exit(); }
int main(int ac, char **av) { sigset_t set, set1, set2; int lc; /* loop counter */ char *msg; /* message returned from parse_opts */ /* parse standard options */ if ((msg = parse_opts(ac, av, (option_t *)NULL, NULL)) != (char *)NULL){ tst_brkm(TBROK, tst_exit, "OPTION PARSING ERROR - %s", msg); } setup(); /* Check looping state if -i option given */ for (lc = 0; TEST_LOOPING(lc); ++lc) { Tst_count = 0; if (sigemptyset(&set) < 0) { tst_brkm(TFAIL|TERRNO, cleanup, "sigemptyset failed"); } #ifdef __x86_64__ struct kernel_sigaction act, oact; sig_initial(SIGALRM); memset(&act,0,sizeof(act)); memset(&oact,0,sizeof(oact)); act.sa_flags |= SA_RESTORER; act.sa_restorer = restore_rt; act.k_sa_handler = sig_handler; #else struct sigaction act, oact; memset(&act,0,sizeof(act)); memset(&oact,0,sizeof(oact)); act.sa_handler = sig_handler; #endif TEST(syscall(__NR_rt_sigaction, SIGALRM, &act, &oact, SIGSETSIZE)); if (TEST_RETURN == -1) { tst_brkm(TFAIL|TTERRNO, cleanup, "rt_sigaction failed"); } TEST(syscall(__NR_rt_sigprocmask, SIG_UNBLOCK, 0, &set1, SIGSETSIZE)); if (TEST_RETURN == -1) { tst_brkm(TFAIL|TTERRNO, cleanup, "rt_sigprocmask failed"); } TEST(alarm(5)); int result; TEST(result = syscall(__NR_rt_sigsuspend, &set, SIGSETSIZE)); TEST(alarm(0)); if (result == -1 && TEST_ERRNO != EINTR) { TEST(syscall(__NR_rt_sigprocmask, SIG_UNBLOCK, 0, &set2, SIGSETSIZE)); if (TEST_RETURN == -1) { tst_brkm(TFAIL|TTERRNO, cleanup, "rt_sigprocmask failed"); } else if (set1.__val[0] != set2.__val[0]) { tst_brkm(TFAIL|TTERRNO, cleanup, "rt_sigsuspend failed to " "preserve signal mask"); } else { tst_resm(TPASS, "rt_sigsuspend PASSED"); } } else { tst_resm(TFAIL|TTERRNO, "rt_sigsuspend failed"); } } cleanup(); /* NOTREACHED */ return 1; }
int main(int ac, char **av) { #if __x86_64 struct kernel_sigaction act, oact; sig_initial(TEST_SIG); act.sa_flags |= SA_RESTORER; act.sa_restorer = restore_rt; act.k_sa_handler = sig_handler; #else struct sigaction act, oact; memset(&act, 0, sizeof(act)); memset(&oact, 0, sizeof(oact)); act.sa_handler = sig_handler; #endif sigset_t set, oset; int lc; char *msg; if ((msg = parse_opts(ac, av, NULL, NULL)) != NULL) { tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg); } setup(); for (lc = 0; TEST_LOOPING(lc); ++lc) { Tst_count = 0; for (testno = 0; testno < TST_TOTAL; ++testno) { if (sigemptyset(&set) < 0) { tst_brkm(TFAIL | TERRNO, cleanup, "sigemptyset call failed"); } if (sigaddset(&set, TEST_SIG) < 0) { tst_brkm(TFAIL | TERRNO, cleanup, "sigaddset call failed"); } /* call rt_sigaction() */ TEST(syscall(__NR_rt_sigaction, TEST_SIG, &act, &oact, SIGSETSIZE)); if (TEST_RETURN < 0) { tst_brkm(TFAIL | TTERRNO, cleanup, "rt_sigaction call failed"); } /* call rt_sigprocmask() to block signal#TEST_SIG */ TEST(syscall(__NR_rt_sigprocmask, SIG_BLOCK, &set, &oset, SIGSETSIZE)); if (TEST_RETURN == -1) { tst_brkm(TFAIL | TTERRNO, cleanup, "rt_sigprocmask call failed"); } /* Make sure that the masked process is indeed * masked. */ if (kill(getpid(), TEST_SIG) < 0) { tst_brkm(TFAIL | TERRNO, cleanup, "call to kill() failed"); } if (sig_count) { tst_brkm(TFAIL | TERRNO, cleanup, "rt_sigprocmask() failed to change " "the process's signal mask"); } else { /* call rt_sigpending() */ TEST(syscall(__NR_rt_sigpending, &oset, SIGSETSIZE)); if (TEST_RETURN == -1) { tst_brkm(TFAIL | TTERRNO, cleanup, "rt_sigpending call failed"); } TEST(sigismember(&oset, TEST_SIG)); if (TEST_RETURN == 0) { tst_brkm(TFAIL | TTERRNO, cleanup, "sigismember call failed"); } /* call rt_sigprocmask() to unblock * signal#TEST_SIG */ TEST(syscall(__NR_rt_sigprocmask, SIG_UNBLOCK, &set, &oset, SIGSETSIZE)); if (TEST_RETURN == -1) { tst_brkm(TFAIL | TTERRNO, cleanup, "rt_sigprocmask call failed"); } if (sig_count) { tst_resm(TPASS, "rt_sigprocmask " "functionality passed"); break; } else { tst_brkm(TFAIL | TERRNO, cleanup, "rt_sigprocmask " "functionality failed"); } } } Tst_count++; } cleanup(); tst_exit(); }