Example #1
0
OBJECT cpu_event_wait_child(STATE, cpu c, OBJECT channel, int pid, int flags) {
  struct thread_info *ti;
  OBJECT id;

  ti = ALLOC_N(struct thread_info, 1);
  ti->fd = 0;
  ti->state = state;
  ti->c = c;
  ti->pid = pid;
  ti->options = flags;
  ti->type = WAITER;
  ti->channel = channel;
  ti->stopper = NULL;
  
  id = _cpu_event_register_info(state, ti);

  /* todo: we can mitigate O(N^2) complexity for waitpid calls by
     only looking for potentially matching watchers. */
  cpu_find_waiters(state); // run once right away, in case SIGCHLD has already been caught

  return id;
}
Example #2
0
static void _find_child_waiters(int key, void *mach) {
  machine m = mach;
  cpu_find_waiters(m->s);
}