/* Check that we have indeed attached to the thing..  */
int ptrace_check_attach(struct task_struct *child, int kill)
/* Check that we have indeed attached to the thing..  */
int ptrace_check_attach(struct task_struct *child, int kill)
{
	int ret = -ESRCH;
	read_lock(&tasklist_lock);
	if ((child->ptrace & PT_PTRACED) && child->parent == current) {
		ret = 0;
		spin_lock_irq(&child->sighand->siglock);
		if (task_is_stopped(child))
			child->state = TASK_TRACED;
		else if (!task_is_traced(child) && !kill)
			ret = -ESRCH;
		spin_unlock_irq(&child->sighand->siglock);
	}
	read_unlock(&tasklist_lock);
	if (!ret && !kill)
		ret = wait_task_inactive(child, TASK_TRACED) ? 0 : -ESRCH;
	return ret;
}