diff options
Diffstat (limited to 'kernel/exit.c')
-rw-r--r-- | kernel/exit.c | 45 |
1 files changed, 21 insertions, 24 deletions
diff --git a/kernel/exit.c b/kernel/exit.c index 9d6e0897a447..b4d569675d4b 100644 --- a/kernel/exit.c +++ b/kernel/exit.c | |||
@@ -1158,8 +1158,7 @@ static int wait_task_zombie(struct task_struct *p, int noreap, | |||
1158 | int __user *stat_addr, struct rusage __user *ru) | 1158 | int __user *stat_addr, struct rusage __user *ru) |
1159 | { | 1159 | { |
1160 | unsigned long state; | 1160 | unsigned long state; |
1161 | int retval; | 1161 | int retval, status, traced; |
1162 | int status; | ||
1163 | 1162 | ||
1164 | if (unlikely(noreap)) { | 1163 | if (unlikely(noreap)) { |
1165 | pid_t pid = p->pid; | 1164 | pid_t pid = p->pid; |
@@ -1201,7 +1200,10 @@ static int wait_task_zombie(struct task_struct *p, int noreap, | |||
1201 | return 0; | 1200 | return 0; |
1202 | } | 1201 | } |
1203 | 1202 | ||
1204 | if (likely(p->real_parent == p->parent)) { | 1203 | /* traced means p->ptrace, but not vice versa */ |
1204 | traced = (p->real_parent != p->parent); | ||
1205 | |||
1206 | if (likely(!traced)) { | ||
1205 | struct signal_struct *psig; | 1207 | struct signal_struct *psig; |
1206 | struct signal_struct *sig; | 1208 | struct signal_struct *sig; |
1207 | 1209 | ||
@@ -1288,35 +1290,30 @@ static int wait_task_zombie(struct task_struct *p, int noreap, | |||
1288 | retval = put_user(p->pid, &infop->si_pid); | 1290 | retval = put_user(p->pid, &infop->si_pid); |
1289 | if (!retval && infop) | 1291 | if (!retval && infop) |
1290 | retval = put_user(p->uid, &infop->si_uid); | 1292 | retval = put_user(p->uid, &infop->si_uid); |
1291 | if (retval) { | 1293 | if (!retval) |
1292 | // TODO: is this safe? | 1294 | retval = p->pid; |
1293 | p->exit_state = EXIT_ZOMBIE; | 1295 | |
1294 | return retval; | 1296 | if (traced) { |
1295 | } | ||
1296 | retval = p->pid; | ||
1297 | if (p->real_parent != p->parent) { | ||
1298 | write_lock_irq(&tasklist_lock); | 1297 | write_lock_irq(&tasklist_lock); |
1299 | /* Double-check with lock held. */ | 1298 | /* We dropped tasklist, ptracer could die and untrace */ |
1300 | if (p->real_parent != p->parent) { | 1299 | ptrace_unlink(p); |
1301 | __ptrace_unlink(p); | 1300 | /* |
1302 | // TODO: is this safe? | 1301 | * If this is not a detached task, notify the parent. |
1303 | p->exit_state = EXIT_ZOMBIE; | 1302 | * If it's still not detached after that, don't release |
1304 | /* | 1303 | * it now. |
1305 | * If this is not a detached task, notify the parent. | 1304 | */ |
1306 | * If it's still not detached after that, don't release | 1305 | if (p->exit_signal != -1) { |
1307 | * it now. | 1306 | do_notify_parent(p, p->exit_signal); |
1308 | */ | ||
1309 | if (p->exit_signal != -1) { | 1307 | if (p->exit_signal != -1) { |
1310 | do_notify_parent(p, p->exit_signal); | 1308 | p->exit_state = EXIT_ZOMBIE; |
1311 | if (p->exit_signal != -1) | 1309 | p = NULL; |
1312 | p = NULL; | ||
1313 | } | 1310 | } |
1314 | } | 1311 | } |
1315 | write_unlock_irq(&tasklist_lock); | 1312 | write_unlock_irq(&tasklist_lock); |
1316 | } | 1313 | } |
1317 | if (p != NULL) | 1314 | if (p != NULL) |
1318 | release_task(p); | 1315 | release_task(p); |
1319 | BUG_ON(!retval); | 1316 | |
1320 | return retval; | 1317 | return retval; |
1321 | } | 1318 | } |
1322 | 1319 | ||