8000 minix/minix/tests/test42.c at master · dbb4560/minix · GitHub
[go: up one dir, main page]

Skip to content

Latest commit

 

History

History
1509 lines (1070 loc) · 30.6 KB

test42.c

File metadata and controls

1509 lines (1070 loc) · 30.6 KB
if (ptrace(T_DETACH, pid, 0, 0) == 0) my_e(10);
if (errno != EBUSY) my_e(11);
detach_running(pid);
WRITE(0);
traced_wait();
}
void test_detach_child()
{
struct sigaction sa;
sigset_t set, sset, oset;
sa.sa_handler = catch_handler;
sigemptyset(&sa.sa_mask);
sa.sa_flags = SA_NODEFER;
sigaction(SIGUSR1, &sa, NULL);
sigaction(SIGUSR2, &sa, NULL);
sigaction(SIGTERM, &sa, NULL);
sigfillset(&set);
sigprocmask(SIG_SETMASK, &set, &oset);
sigfillset(&sset);
sigdelset(&sset, SIGUSR1);
caught = 0;
WRITE(0);
if (sigsuspend(&sset) != -1) my_e(102);
if (errno != EINTR) my_e(103);
if (caught != 1) my_e(104);
if (READ() != 0) my_e(105);
while (caught != 7) sigsuspend(&oset);
exit(42);
}
void test_detach()
{
pid_t pid;
int r, status;
/* Can't use traced_fork(), so simplify a bit */
if (attach != 0) return;
subtest = 10;
pid = traced_pfork(test_detach_child);
if (READ() != 0) my_e(1);
/* The tracer should not see signals sent to the process before attaching. */
if (kill(pid, SIGUSR2) != 0) my_e(2);
if (ptrace(T_ATTACH, pid, 0, 0) != 0) my_e(3);
if (waitpid(pid, &status, 0) != pid) my_e(4);
if (!_WIFSTOPPED(status)) my_e(5);
if (WSTOPSIG(status) != SIGSTOP) my_e(6);
if (ptrace(T_RESUME, pid, 0, 0) != 0) my_e(7);
if (kill(pid, SIGUSR1) != 0) my_e(8);
if (waitpid(pid, &status, 0) != pid) my_e(9);
if (!_WIFSTOPPED(status)) my_e(10);
if (WSTOPSIG(status) != SIGUSR1) my_e(11);
/* Signals pending at the tracer should be passed on after detaching. */
0