static __attribute__((__noreturn__)) void child_alrm (void)
{
- void (*handler_orig) (int signo);
#if 0
int i;
sigset_t oldset;
#endif
- handler_orig = signal (SIGALRM, child_alrm_handler);
- assert (handler_orig == SIG_DFL);
+ /* Assumed already setup SIGALRM for CHILD_ALRM_HANDLER. */
#if 0
i = sigprocmask (SIG_BLOCK, NULL, &oldset);
pid_t inferior;
struct attach_state_struct *attach_state;
int i;
+ void (*handler_orig) (int signo);
assert (input == NULL);
murder (inferior);
/* Attach to a stopped process with already pending SIGALRM. */
+ /* Setup the handler already in the parent to avoid the child race. */
+ handler_orig = signal (SIGALRM, child_alrm_handler);
+ assert (handler_orig == SIG_DFL);
inferior = (unsigned long) (*child) (data, child_alrm);
+ handler_orig = signal (SIGALRM, handler_orig);
+ assert (handler_orig == child_alrm_handler);
STATE (inferior, 1 << STATE_SLEEPING);
delay ();
i = tkill (inferior, SIGSTOP);