aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--kernel/exit.c30
1 files changed, 18 insertions, 12 deletions
diff --git a/kernel/exit.c b/kernel/exit.c
index 167e1e3ad7c6..0c06b9efae3b 100644
--- a/kernel/exit.c
+++ b/kernel/exit.c
@@ -1417,6 +1417,18 @@ static int wait_task_zombie(struct task_struct *p, int options,
1417 return retval; 1417 return retval;
1418} 1418}
1419 1419
1420static int *task_stopped_code(struct task_struct *p, bool ptrace)
1421{
1422 if (ptrace) {
1423 if (task_is_stopped_or_traced(p))
1424 return &p->exit_code;
1425 } else {
1426 if (p->signal->flags & SIGNAL_STOP_STOPPED)
1427 return &p->signal->group_exit_code;
1428 }
1429 return NULL;
1430}
1431
1420/* 1432/*
1421 * Handle sys_wait4 work for one task in state TASK_STOPPED. We hold 1433 * Handle sys_wait4 work for one task in state TASK_STOPPED. We hold
1422 * read_lock(&tasklist_lock) on entry. If we return zero, we still hold 1434 * read_lock(&tasklist_lock) on entry. If we return zero, we still hold
@@ -1427,7 +1439,7 @@ static int wait_task_stopped(int ptrace, struct task_struct *p,
1427 int options, struct siginfo __user *infop, 1439 int options, struct siginfo __user *infop,
1428 int __user *stat_addr, struct rusage __user *ru) 1440 int __user *stat_addr, struct rusage __user *ru)
1429{ 1441{
1430 int retval, exit_code, why; 1442 int retval, exit_code, *p_code, why;
1431 uid_t uid = 0; /* unneeded, required by compiler */ 1443 uid_t uid = 0; /* unneeded, required by compiler */
1432 pid_t pid; 1444 pid_t pid;
1433 1445
@@ -1437,22 +1449,16 @@ static int wait_task_stopped(int ptrace, struct task_struct *p,
1437 exit_code = 0; 1449 exit_code = 0;
1438 spin_lock_irq(&p->sighand->siglock); 1450 spin_lock_irq(&p->sighand->siglock);
1439 1451
1440 if (unlikely(!task_is_stopped_or_traced(p))) 1452 p_code = task_stopped_code(p, ptrace);
1441 goto unlock_sig; 1453 if (unlikely(!p_code))
1442
1443 if (!ptrace && p->signal->group_stop_count > 0)
1444 /*
1445 * A group stop is in progress and this is the group leader.
1446 * We won't report until all threads have stopped.
1447 */
1448 goto unlock_sig; 1454 goto unlock_sig;
1449 1455
1450 exit_code = p->exit_code; 1456 exit_code = *p_code;
1451 if (!exit_code) 1457 if (!exit_code)
1452 goto unlock_sig; 1458 goto unlock_sig;
1453 1459
1454 if (!unlikely(options & WNOWAIT)) 1460 if (!unlikely(options & WNOWAIT))
1455 p->exit_code = 0; 1461 *p_code = 0;
1456 1462
1457 /* don't need the RCU readlock here as we're holding a spinlock */ 1463 /* don't need the RCU readlock here as we're holding a spinlock */
1458 uid = __task_cred(p)->uid; 1464 uid = __task_cred(p)->uid;
@@ -1608,7 +1614,7 @@ static int wait_consider_task(struct task_struct *parent, int ptrace,
1608 */ 1614 */
1609 *notask_error = 0; 1615 *notask_error = 0;
1610 1616
1611 if (task_is_stopped_or_traced(p)) 1617 if (task_stopped_code(p, ptrace))
1612 return wait_task_stopped(ptrace, p, options, 1618 return wait_task_stopped(ptrace, p, options,
1613 infop, stat_addr, ru); 1619 infop, stat_addr, ru);
1614 1620