lkml.org 
[lkml]   [2004]   [Oct]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
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:

http://www.kernel.org/pub/linux/kernel/people/akpm/patches/2.6/2.6.9/2.6.9-mm1/broken-out/acct-report-single-record-for-multithreaded-process.patch


Then throw this one on top.


Thanks,
Roland


---

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 <roland@redhat.com>

--- 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;

profile_task_exit(tsk);

@@ -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)
acct_process(code);
__exit_mm(tsk);

@@ -818,7 +820,7 @@ asmlinkage NORET_TYPE void do_exit(long
exit_thread();
exit_keys(tsk);

- if (tsk->signal->leader)
+ if (group_dead && tsk->signal->leader)
disassociate_ctty(1);

module_put(tsk->thread_info->exec_domain->module);
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
\
 
 \ /
  Last update: 2005-03-22 14:07    [W:0.358 / U:0.204 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site