1. exit_notify() always calls kill_orphaned_pgrp(). This is wrong, we
should do this only when the whole process exits.
2. exit_notify() uses "current" as "ignored_task", obviously wrong.
Use ->group_leader instead.
Test case:
void hup(int sig)
{
printf("HUP received\n");
}
void *tfunc(void *arg)
{
sleep(2);
printf("sub-thread exited\n");
return NULL;
}
int main(int argc, char *argv[])
{
if (!fork()) {
signal(SIGHUP, hup);
kill(getpid(), SIGSTOP);
exit(0);
}
pthread_t thr;
pthread_create(&thr, NULL, tfunc, NULL);
sleep(1);
printf("main thread exited\n");
syscall(__NR_exit, 0);
return 0;
}
output:
main thread exited
HUP received
Hangup
With this patch the output is:
main thread exited
sub-thread exited
HUP received
Signed-off-by: Oleg Nesterov <oleg@tv-sign.ru>
--- 25/kernel/exit.c~3_OG_EXIT 2008-03-02 19:42:56.000000000 +0300
+++ 25/kernel/exit.c 2008-03-02 21:21:51.000000000 +0300
@@ -754,7 +754,7 @@ static void forget_original_parent(struc
* Send signals to all our closest relatives so that they know
* to properly mourn us..
*/
-static void exit_notify(struct task_struct *tsk)
+static void exit_notify(struct task_struct *tsk, int group_dead)
{
int state;
@@ -770,7 +770,8 @@ static void exit_notify(struct task_stru
exit_task_namespaces(tsk);
write_lock_irq(&tasklist_lock);
- kill_orphaned_pgrp(tsk, NULL);
+ if (group_dead)
+ kill_orphaned_pgrp(tsk->group_leader, NULL);
/* Let father know we died
*
@@ -985,7 +986,7 @@ NORET_TYPE void do_exit(long code)
module_put(tsk->binfmt->module);
proc_exit_connector(tsk);
- exit_notify(tsk);
+ exit_notify(tsk, group_dead);
#ifdef CONFIG_NUMA
mpol_free(tsk->mempolicy);
tsk->mempolicy = NULL;
--
| Linus Torvalds | Linux 2.6.27-rc8 |
| Rafael J. Wysocki | 2.6.26-rc9-git12: Reported regressions from 2.6.25 |
| Alan Cox | [PATCH 00/76] Queued TTY Patches |
| James Bottomley | Re: Integration of SCST in the mainstream Linux kernel |
git: | |
| Shawn O. Pearce | Re: cleaner/better zlib sources? |
| sbejar | Re: Using GIT to store /etc (Or: How to make GIT store all file permission bits) |
| Mark Levedahl | mingw, windows, crlf/lf, and git |
| bain | [Announce] teamGit v0.0.3 |
| Richard Stallman | Real men don't attack straw men |
| Leon Dippenaar | New tcp stack attack |
| Jonathan Thornburg | svnd questions (encrypting all of a partition or disk) |
| Chris Bullock | OpenBSD isakmpd and pf vs Cisco PIX or ASA |
| Gerrit Renker | [PATCH 0/37] dccp: Feature negotiation - last call for comments |
| Dushan Tcholich | Re: ksoftirqd high cpu load on kernels 2.6.24 to 2.6.27-rc1-mm1 |
| Jarek Poplawski | Re: [PATCH] Fix routing tables with id > 255 for legacy software |
| Evgeniy Polyakov | Re: [Bugme-new] [Bug 10556] New: IPVS sync_backup oops |
