Skip to content

Commit 76d9871

Browse files
author
Al Viro
committed
wait_task_zombie: consolidate info logics
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
1 parent bb380ec commit 76d9871

File tree

1 file changed

+16
-29
lines changed

1 file changed

+16
-29
lines changed

kernel/exit.c

Lines changed: 16 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1074,28 +1074,14 @@ static int wait_task_zombie(struct wait_opts *wo, struct task_struct *p)
10741074
return 0;
10751075

10761076
if (unlikely(wo->wo_flags & WNOWAIT)) {
1077-
int exit_code = p->exit_code;
1078-
1077+
status = p->exit_code;
10791078
get_task_struct(p);
10801079
read_unlock(&tasklist_lock);
10811080
sched_annotate_sleep();
10821081
if (wo->wo_rusage)
10831082
getrusage(p, RUSAGE_BOTH, wo->wo_rusage);
10841083
put_task_struct(p);
1085-
1086-
infop = wo->wo_info;
1087-
if (infop) {
1088-
if ((exit_code & 0x7f) == 0) {
1089-
infop->cause = CLD_EXITED;
1090-
infop->status = exit_code >> 8;
1091-
} else {
1092-
infop->cause = (exit_code & 0x80) ? CLD_DUMPED : CLD_KILLED;
1093-
infop->status = exit_code & 0x7f;
1094-
}
1095-
infop->pid = pid;
1096-
infop->uid = uid;
1097-
}
1098-
return pid;
1084+
goto out_info;
10991085
}
11001086
/*
11011087
* Move the task's state to DEAD/TRACE, only one thread can do this.
@@ -1174,19 +1160,6 @@ static int wait_task_zombie(struct wait_opts *wo, struct task_struct *p)
11741160
? p->signal->group_exit_code : p->exit_code;
11751161
wo->wo_stat = status;
11761162

1177-
infop = wo->wo_info;
1178-
if (infop) {
1179-
if ((status & 0x7f) == 0) {
1180-
infop->cause = CLD_EXITED;
1181-
infop->status = status >> 8;
1182-
} else {
1183-
infop->cause = (status & 0x80) ? CLD_DUMPED : CLD_KILLED;
1184-
infop->status = status & 0x7f;
1185-
}
1186-
infop->pid = pid;
1187-
infop->uid = uid;
1188-
}
1189-
11901163
if (state == EXIT_TRACE) {
11911164
write_lock_irq(&tasklist_lock);
11921165
/* We dropped tasklist, ptracer could die and untrace */
@@ -1202,6 +1175,20 @@ static int wait_task_zombie(struct wait_opts *wo, struct task_struct *p)
12021175
if (state == EXIT_DEAD)
12031176
release_task(p);
12041177

1178+
out_info:
1179+
infop = wo->wo_info;
1180+
if (infop) {
1181+
if ((status & 0x7f) == 0) {
1182+
infop->cause = CLD_EXITED;
1183+
infop->status = status >> 8;
1184+
} else {
1185+
infop->cause = (status & 0x80) ? CLD_DUMPED : CLD_KILLED;
1186+
infop->status = status & 0x7f;
1187+
}
1188+
infop->pid = pid;
1189+
infop->uid = uid;
1190+
}
1191+
12051192
return pid;
12061193
}
12071194

0 commit comments

Comments
 (0)