[lkml]   [2004]   [Oct]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
Patch in this message
SubjectRe: NPTL: Parent thread receives SIGHUP when child thread terminates?
>   When process is session leader, is it supposed to receive SIGHUP when child
> thread terminates?

Nope, this is certainly wrong.

> Probably disassociate_ctty(1) in do_exit() should not be invoked for all
> tsk->signal->leader, but only for those with thread_group_empty() == 1, i.e.
> when this process is really going away ? Or only for thread group leader?

Indeed, but that particular kind of test is subject to race conditions. I
think the easiest way to fix this is to use the bookkeeping I added to get
process accounting correct (another thing that has to happen on the last
thread's death). Start with this patch:

Then throw this one on top.



The session leader should disassociate from its controlling terminal and
send SIGHUP signals only when the whole session leader process dies.
Currently, this gets done when any thread in that process dies, which is
wrong. This patch fixes it.

Signed-off-by: Roland McGrath <>

--- linux-2.6/kernel/exit.c.acct
+++ linux-2.6/kernel/exit.c
@@ -783,6 +783,7 @@ static void exit_notify(struct task_stru
asmlinkage NORET_TYPE void do_exit(long code)
struct task_struct *tsk = current;
+ int group_dead;


@@ -807,7 +808,8 @@ asmlinkage NORET_TYPE void do_exit(long
ptrace_notify((PTRACE_EVENT_EXIT << 8) | SIGTRAP);

- if (atomic_dec_and_test(&tsk->signal->live))
+ group_dead = atomic_dec_and_test(&tsk->signal->live);
+ if (group_dead)

@@ -818,7 +820,7 @@ asmlinkage NORET_TYPE void do_exit(long

- if (tsk->signal->leader)
+ if (group_dead && tsk->signal->leader)

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
More majordomo info at
Please read the FAQ at
 \ /
  Last update: 2005-03-22 14:07    [W:0.053 / U:0.092 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site