13 void job_handler(int sig, siginfo_t *si, void *ctx)
18 if (si->si_code == CLD_STOPPED) {
20 kill(si->si_pid, SIGCONT);
21 } else if (si->si_code == CLD_EXITED) {
22 ret = waitpid(si->si_pid, &status, 0);
25 if (!WIFEXITED(status))
26 errx(1, "!WIFEXITED(status)");
28 } else if (si->si_code == CLD_CONTINUED) {
33 void job_control_test()
39 sigemptyset(&sa.sa_mask);
40 sa.sa_flags = SA_SIGINFO;
41 sa.sa_sigaction = job_handler;
42 sigaction(SIGCHLD, &sa, NULL);
48 kill(getpid(), SIGSTOP);
52 while (!(cont_received && stop_received && exit_received)) {
57 if (!(cont_received && stop_received && exit_received))
58 errx(1, "job signals lost");
60 printf("job control test OK.\n");
63 void rtsig_handler(int sig, siginfo_t *si, void *ctx)
73 /* test job control with empty signal queue */
76 /* now full fill signal queue in kernel */
77 sigemptyset(&sa.sa_mask);
78 sa.sa_flags = SA_SIGINFO;
79 sa.sa_sigaction = rtsig_handler;
80 sigaction(SIGRTMIN, &sa, NULL);
82 sigaddset(&set, SIGRTMIN);
83 sigprocmask(SIG_BLOCK, &set, NULL);
85 while (sigqueue(getpid(), SIGRTMIN, val))
88 /* signal queue is fully filled, test the job control again. */