The attched patch adds the PR_DETACH prctl command.I know, thanks for the review. That's basically an RFC material.
Hi. The patch doesn't look right at first glance,
Well. You should somehow convince people we need this ;)I don't have to: I need this patch, and that's the main motivation
Only current can change its ->flags, this is racyOh my, add a new lock only for that? :((
Thanks, will fix.+ if (!ptrace_reparented(p))No, we can't do this under read_lock(tasklist). And you forgot about
+ p->parent = init_pid_ns.child_reaper;
+ p->real_parent = init_pid_ns.child_reaper;
+ p->exit_signal = SIGCHLD;
+ list_move_tail(&p->sibling,&p->real_parent->children);
threads, they also have ->real_parent == old_parent.
The usage of ->exit_code doesn't look right, espeicaily if it is traced.Could you please elaborate on that? I am using the
What if it is already dead? We are goint to reparent it, but initWill fix.
won't notice the new zombie.
And what if do_wait() was called without WEXITED? say, the old parent
does waitpid(WSTOPPED).
Will fix the problem with parent ignoring SIGCHLD, thanks.@@ -1450,10 +1450,10 @@ int do_notify_parent(struct task_struct *tsk, int sig)Afaics, you are trying to hide the problem.... The code below can make
BUG_ON(sig == -1);
- /* do_notify_parent_cldstop should have been called instead. */
- BUG_ON(task_is_stopped_or_traced(tsk));
+ /* do_notify_parent_cldstop should have been called instead. */
+ BUG_ON(task_is_stopped_or_traced(tsk));
- BUG_ON(!task_ptrace(tsk)&&
+ BUG_ON(!task_ptrace(tsk)&& (tsk->flags& PF_EXITING)&&
(tsk->group_leader != tsk || !thread_group_empty(tsk)));
tsk detached if real_parent ignores SIGCHLD.
Will fix.--- a/kernel/sys.cThis is not exactly right. What if the child of init's sub-thread
+++ b/kernel/sys.c
@@ -1736,6 +1736,22 @@ SYSCALL_DEFINE5(prctl, int, option, unsigned long, arg2, unsigned long, arg3,
else
error = PR_MCE_KILL_DEFAULT;
break;
+ case PR_DETACH:
+ error = -EPERM;
+ /* if parent is init, or not a group leader - bail */
+ if (me->real_parent == init_pid_ns.child_reaper)
does PR_DETACH?