/* When we die, we re-parent all our children. Try to give them to another thread in our thread group, and if no such member exists, give it to the child reaper process (ie "init") in our pid space.  */
static struct task_struct* find_new_reaper(struct task_struct *father)
/* When we die, we re-parent all our children. Try to give them to another thread in our thread group, and if no such member exists, give it to the child reaper process (ie "init") in our pid space.  */
static struct task_struct* find_new_reaper(struct task_struct *father)
{
	struct pid_namespace *pid_ns = task_active_pid_ns(father);
	struct task_struct *thread;
	thread = father;
	while_each_thread(father, thread) {
		if (thread->flags & PF_EXITING)
			continue;
		if (unlikely(pid_ns->child_reaper == father))
			pid_ns->child_reaper = thread;
		return thread;
	}
	if (unlikely(pid_ns->child_reaper == father)) {
		write_unlock_irq(&tasklist_lock);
		if (unlikely(pid_ns == &init_pid_ns))
			panic("Attempted to kill init!");
		zap_pid_ns_processes(pid_ns);
		write_lock_irq(&tasklist_lock);
		pid_ns->child_reaper = init_pid_ns.child_reaper;
	}
	return pid_ns->child_reaper;
}