static void do_child_1(void) { pid_t pid, group; int i; group = SAFE_GETPGID(0); for (i = 0; i < MAXKIDS; i++) { if (i == (MAXKIDS / 2)) SAFE_SETPGID(0, 0); pid = SAFE_FORK(); if (pid == 0) do_exit(0); fork_kid_pid[i] = pid; } TST_CHECKPOINT_WAKE2(0, MAXKIDS); if (reap_children(0, 0, fork_kid_pid + (MAXKIDS / 2), MAXKIDS / 2)) return; /* Make sure can pickup children in a diff. process group */ if (reap_children(-group, 0, fork_kid_pid, MAXKIDS / 2)) return; tst_res(TPASS, "Test PASSED"); }
static int fork_testrun(void) { int status; if (tst_test->timeout) tst_set_timeout(tst_test->timeout); else tst_set_timeout(300); SAFE_SIGNAL(SIGINT, sigint_handler); test_pid = fork(); if (test_pid < 0) tst_brk(TBROK | TERRNO, "fork()"); if (!test_pid) { SAFE_SIGNAL(SIGALRM, SIG_DFL); SAFE_SIGNAL(SIGUSR1, SIG_DFL); SAFE_SIGNAL(SIGINT, SIG_DFL); SAFE_SETPGID(0, 0); testrun(); } SAFE_WAITPID(test_pid, &status, 0); alarm(0); SAFE_SIGNAL(SIGINT, SIG_DFL); if (WIFEXITED(status) && WEXITSTATUS(status)) return WEXITSTATUS(status); if (WIFSIGNALED(status) && WTERMSIG(status) == SIGKILL) { tst_res(TINFO, "If you are running on slow machine, " "try exporting LTP_TIMEOUT_MUL > 1"); tst_brk(TBROK, "Test killed! (timeout?)"); } if (WIFSIGNALED(status)) tst_brk(TBROK, "Test killed by %s!", tst_strsig(WTERMSIG(status))); return 0; }
static void do_child_1(void) { pid_t pid, group; int i; int status; group = SAFE_GETPGID(0); for (i = 0; i < MAXKIDS; i++) { if (i == (MAXKIDS / 2)) SAFE_SETPGID(0, 0); pid = SAFE_FORK(); if (pid == 0) do_exit(0); fork_kid_pid[i] = pid; } if (TST_TRACE(waitpid_ret_test(0, &status, WNOHANG, 0, 0))) return; if (TST_TRACE(waitpid_ret_test(-group, &status, WNOHANG, 0, 0))) return; TST_CHECKPOINT_WAKE2(0, MAXKIDS); if (TST_TRACE(reap_children(0, WNOHANG, fork_kid_pid + (MAXKIDS / 2), MAXKIDS / 2))) return; if (TST_TRACE(reap_children(-group, WNOHANG, fork_kid_pid, MAXKIDS / 2))) return; tst_res(TPASS, "Test PASSED"); }