tracehook: death
This moves the ptrace logic in task death (exit_notify) into tracehook.h inlines. Some code is rearranged slightly to make things nicer. There is no change, only cleanup. There is one hook called with the tasklist_lock write-locked, as ptrace needs. There is also a new hook called after exit_state changes and without locks. This is a better place for tracing work to be in the future, since it doesn't delay the whole system with locking. Signed-off-by: Roland McGrath <roland@redhat.com> Cc: Oleg Nesterov <oleg@tv-sign.ru> Reviewed-by: Ingo Molnar <mingo@elte.hu> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:

committed by
Linus Torvalds

parent
fa00b80b3c
commit
2b2a1ff64a
@@ -471,4 +471,56 @@ static inline int tracehook_notify_jctl(int notify, int why)
|
||||
return notify || (current->ptrace & PT_PTRACED);
|
||||
}
|
||||
|
||||
/**
|
||||
* tracehook_notify_death - task is dead, ready to notify parent
|
||||
* @task: @current task now exiting
|
||||
* @death_cookie: value to pass to tracehook_report_death()
|
||||
* @group_dead: nonzero if this was the last thread in the group to die
|
||||
*
|
||||
* Return the signal number to send our parent with do_notify_parent(), or
|
||||
* zero to send no signal and leave a zombie, or -1 to self-reap right now.
|
||||
*
|
||||
* Called with write_lock_irq(&tasklist_lock) held.
|
||||
*/
|
||||
static inline int tracehook_notify_death(struct task_struct *task,
|
||||
void **death_cookie, int group_dead)
|
||||
{
|
||||
if (task->exit_signal == -1)
|
||||
return task->ptrace ? SIGCHLD : -1;
|
||||
|
||||
/*
|
||||
* If something other than our normal parent is ptracing us, then
|
||||
* send it a SIGCHLD instead of honoring exit_signal. exit_signal
|
||||
* only has special meaning to our real parent.
|
||||
*/
|
||||
if (thread_group_empty(task) && !ptrace_reparented(task))
|
||||
return task->exit_signal;
|
||||
|
||||
return task->ptrace ? SIGCHLD : 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* tracehook_report_death - task is dead and ready to be reaped
|
||||
* @task: @current task now exiting
|
||||
* @signal: signal number sent to parent, or 0 or -1
|
||||
* @death_cookie: value passed back from tracehook_notify_death()
|
||||
* @group_dead: nonzero if this was the last thread in the group to die
|
||||
*
|
||||
* Thread has just become a zombie or is about to self-reap. If positive,
|
||||
* @signal is the signal number just sent to the parent (usually %SIGCHLD).
|
||||
* If @signal is -1, this thread will self-reap. If @signal is 0, this is
|
||||
* a delayed_group_leader() zombie. The @death_cookie was passed back by
|
||||
* tracehook_notify_death().
|
||||
*
|
||||
* If normal reaping is not inhibited, @task->exit_state might be changing
|
||||
* in parallel.
|
||||
*
|
||||
* Called without locks.
|
||||
*/
|
||||
static inline void tracehook_report_death(struct task_struct *task,
|
||||
int signal, void *death_cookie,
|
||||
int group_dead)
|
||||
{
|
||||
}
|
||||
|
||||
#endif /* <linux/tracehook.h> */
|
||||
|
Reference in New Issue
Block a user