aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/tracehook.h
diff options
context:
space:
mode:
authorRoland McGrath <roland@redhat.com>2008-07-31 05:04:09 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-08-01 15:01:11 -0400
commit5c7edcd7ee6b77b88252fe4096dce1a46a60c829 (patch)
tree4936df589df33c671e2e98ea45b89e7f45278f61 /include/linux/tracehook.h
parent1e24b15b267293567a8d752721c7ae63f281325a (diff)
tracehook: fix exit_signal=0 case
My commit 2b2a1ff64afbadac842bbc58c5166962cf4f7664 introduced a regression (sorry about that) for the odd case of exit_signal=0 (e.g. clone_flags=0). This is not a normal use, but it's used by a case in the glibc test suite. Dying with exit_signal=0 sends no signal, but it's supposed to wake up a parent's blocked wait*() calls (unlike the delayed_group_leader case). This fixes tracehook_notify_death() and its caller to distinguish a "signal 0" wakeup from the delayed_group_leader case (with no wakeup). Signed-off-by: Roland McGrath <roland@redhat.com> Tested-by: Serge Hallyn <serue@us.ibm.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'include/linux/tracehook.h')
-rw-r--r--include/linux/tracehook.h21
1 files changed, 13 insertions, 8 deletions
diff --git a/include/linux/tracehook.h b/include/linux/tracehook.h
index b1875582c1a1..12532839f508 100644
--- a/include/linux/tracehook.h
+++ b/include/linux/tracehook.h
@@ -493,16 +493,21 @@ static inline int tracehook_notify_jctl(int notify, int why)
493 * @death_cookie: value to pass to tracehook_report_death() 493 * @death_cookie: value to pass to tracehook_report_death()
494 * @group_dead: nonzero if this was the last thread in the group to die 494 * @group_dead: nonzero if this was the last thread in the group to die
495 * 495 *
496 * Return the signal number to send our parent with do_notify_parent(), or 496 * A return value >= 0 means call do_notify_parent() with that signal
497 * zero to send no signal and leave a zombie, or -1 to self-reap right now. 497 * number. Negative return value can be %DEATH_REAP to self-reap right
498 * now, or %DEATH_DELAYED_GROUP_LEADER to a zombie without notifying our
499 * parent. Note that a return value of 0 means a do_notify_parent() call
500 * that sends no signal, but still wakes up a parent blocked in wait*().
498 * 501 *
499 * Called with write_lock_irq(&tasklist_lock) held. 502 * Called with write_lock_irq(&tasklist_lock) held.
500 */ 503 */
504#define DEATH_REAP -1
505#define DEATH_DELAYED_GROUP_LEADER -2
501static inline int tracehook_notify_death(struct task_struct *task, 506static inline int tracehook_notify_death(struct task_struct *task,
502 void **death_cookie, int group_dead) 507 void **death_cookie, int group_dead)
503{ 508{
504 if (task->exit_signal == -1) 509 if (task->exit_signal == -1)
505 return task->ptrace ? SIGCHLD : -1; 510 return task->ptrace ? SIGCHLD : DEATH_REAP;
506 511
507 /* 512 /*
508 * If something other than our normal parent is ptracing us, then 513 * If something other than our normal parent is ptracing us, then
@@ -512,21 +517,21 @@ static inline int tracehook_notify_death(struct task_struct *task,
512 if (thread_group_empty(task) && !ptrace_reparented(task)) 517 if (thread_group_empty(task) && !ptrace_reparented(task))
513 return task->exit_signal; 518 return task->exit_signal;
514 519
515 return task->ptrace ? SIGCHLD : 0; 520 return task->ptrace ? SIGCHLD : DEATH_DELAYED_GROUP_LEADER;
516} 521}
517 522
518/** 523/**
519 * tracehook_report_death - task is dead and ready to be reaped 524 * tracehook_report_death - task is dead and ready to be reaped
520 * @task: @current task now exiting 525 * @task: @current task now exiting
521 * @signal: signal number sent to parent, or 0 or -1 526 * @signal: return value from tracheook_notify_death()
522 * @death_cookie: value passed back from tracehook_notify_death() 527 * @death_cookie: value passed back from tracehook_notify_death()
523 * @group_dead: nonzero if this was the last thread in the group to die 528 * @group_dead: nonzero if this was the last thread in the group to die
524 * 529 *
525 * Thread has just become a zombie or is about to self-reap. If positive, 530 * Thread has just become a zombie or is about to self-reap. If positive,
526 * @signal is the signal number just sent to the parent (usually %SIGCHLD). 531 * @signal is the signal number just sent to the parent (usually %SIGCHLD).
527 * If @signal is -1, this thread will self-reap. If @signal is 0, this is 532 * If @signal is %DEATH_REAP, this thread will self-reap. If @signal is
528 * a delayed_group_leader() zombie. The @death_cookie was passed back by 533 * %DEATH_DELAYED_GROUP_LEADER, this is a delayed_group_leader() zombie.
529 * tracehook_notify_death(). 534 * The @death_cookie was passed back by tracehook_notify_death().
530 * 535 *
531 * If normal reaping is not inhibited, @task->exit_state might be changing 536 * If normal reaping is not inhibited, @task->exit_state might be changing
532 * in parallel. 537 * in parallel.