diff options
-rw-r--r-- | include/linux/tracehook.h | 21 | ||||
-rw-r--r-- | kernel/exit.c | 6 |
2 files changed, 16 insertions, 11 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 | ||
501 | static inline int tracehook_notify_death(struct task_struct *task, | 506 | static 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. |
diff --git a/kernel/exit.c b/kernel/exit.c index eb4d6470d1d0..38ec40630149 100644 --- a/kernel/exit.c +++ b/kernel/exit.c | |||
@@ -911,10 +911,10 @@ static void exit_notify(struct task_struct *tsk, int group_dead) | |||
911 | tsk->exit_signal = SIGCHLD; | 911 | tsk->exit_signal = SIGCHLD; |
912 | 912 | ||
913 | signal = tracehook_notify_death(tsk, &cookie, group_dead); | 913 | signal = tracehook_notify_death(tsk, &cookie, group_dead); |
914 | if (signal > 0) | 914 | if (signal >= 0) |
915 | signal = do_notify_parent(tsk, signal); | 915 | signal = do_notify_parent(tsk, signal); |
916 | 916 | ||
917 | tsk->exit_state = signal < 0 ? EXIT_DEAD : EXIT_ZOMBIE; | 917 | tsk->exit_state = signal == DEATH_REAP ? EXIT_DEAD : EXIT_ZOMBIE; |
918 | 918 | ||
919 | /* mt-exec, de_thread() is waiting for us */ | 919 | /* mt-exec, de_thread() is waiting for us */ |
920 | if (thread_group_leader(tsk) && | 920 | if (thread_group_leader(tsk) && |
@@ -927,7 +927,7 @@ static void exit_notify(struct task_struct *tsk, int group_dead) | |||
927 | tracehook_report_death(tsk, signal, cookie, group_dead); | 927 | tracehook_report_death(tsk, signal, cookie, group_dead); |
928 | 928 | ||
929 | /* If the process is dead, release it - nobody will wait for it */ | 929 | /* If the process is dead, release it - nobody will wait for it */ |
930 | if (signal < 0) | 930 | if (signal == DEATH_REAP) |
931 | release_task(tsk); | 931 | release_task(tsk); |
932 | } | 932 | } |
933 | 933 | ||