#include #include #include #include #include #include #include #include #include #include #include int main(int argc, char **argv) { int status; pid_t child, wpid; child = fork(); if (child == -1) err(1, "fork"); if (child == 0) { setpgrp(0, 0); #if 1 ptrace(PT_TRACE_ME, 0, NULL, 0); raise(SIGSTOP); #endif #if 1 pid_t child2; child2 = fork(); if (child2 == 0) raise(SIGSTOP); #endif raise(SIGSTOP); __builtin_trap(); } wpid = waitpid(child, &status, WSTOPPED); if (wpid == -1) err(1, "wait"); if (wpid != child) err(1, "wpid != child"); #if 1 ptrace_event_t pe; pe.pe_set_event |= PTRACE_FORK; ptrace(PT_SET_EVENT_MASK, child, &pe, sizeof(pe)); #endif #if 1 ptrace(PT_CONTINUE, child, (void *)1, 0); wpid = waitpid(child, &status, WSTOPPED); if (wpid == -1) err(1, "wait"); if (wpid != child) err(1, "wpid != child"); #endif return 0; }