Skip to content

Commit bb380ec

Browse files
author
Al Viro
committed
kill wait_noreap_copyout()
folds into callers Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
1 parent e61a250 commit bb380ec

File tree

1 file changed

+25
-40
lines changed

1 file changed

+25
-40
lines changed

kernel/exit.c

Lines changed: 25 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1057,22 +1057,6 @@ eligible_child(struct wait_opts *wo, bool ptrace, struct task_struct *p)
10571057
return 1;
10581058
}
10591059

1060-
static int wait_noreap_copyout(struct wait_opts *wo, struct task_struct *p,
1061-
pid_t pid, uid_t uid, int why, int status)
1062-
{
1063-
struct waitid_info *infop;
1064-
1065-
put_task_struct(p);
1066-
infop = wo->wo_info;
1067-
if (infop) {
1068-
infop->cause = why;
1069-
infop->pid = pid;
1070-
infop->uid = uid;
1071-
infop->status = status;
1072-
}
1073-
return pid;
1074-
}
1075-
10761060
/*
10771061
* Handle sys_wait4 work for one task in state EXIT_ZOMBIE. We hold
10781062
* read_lock(&tasklist_lock) on entry. If we return zero, we still hold
@@ -1091,22 +1075,27 @@ static int wait_task_zombie(struct wait_opts *wo, struct task_struct *p)
10911075

10921076
if (unlikely(wo->wo_flags & WNOWAIT)) {
10931077
int exit_code = p->exit_code;
1094-
int why;
10951078

10961079
get_task_struct(p);
10971080
read_unlock(&tasklist_lock);
10981081
sched_annotate_sleep();
10991082
if (wo->wo_rusage)
11001083
getrusage(p, RUSAGE_BOTH, wo->wo_rusage);
1084+
put_task_struct(p);
11011085

1102-
if ((exit_code & 0x7f) == 0) {
1103-
why = CLD_EXITED;
1104-
status = exit_code >> 8;
1105-
} else {
1106-
why = (exit_code & 0x80) ? CLD_DUMPED : CLD_KILLED;
1107-
status = exit_code & 0x7f;
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;
11081097
}
1109-
return wait_noreap_copyout(wo, p, pid, uid, why, status);
1098+
return pid;
11101099
}
11111100
/*
11121101
* Move the task's state to DEAD/TRACE, only one thread can do this.
@@ -1297,11 +1286,10 @@ static int wait_task_stopped(struct wait_opts *wo,
12971286
sched_annotate_sleep();
12981287
if (wo->wo_rusage)
12991288
getrusage(p, RUSAGE_BOTH, wo->wo_rusage);
1289+
put_task_struct(p);
13001290

1301-
if (unlikely(wo->wo_flags & WNOWAIT))
1302-
return wait_noreap_copyout(wo, p, pid, uid, why, exit_code);
1303-
1304-
wo->wo_stat = (exit_code << 8) | 0x7f;
1291+
if (likely(!(wo->wo_flags & WNOWAIT)))
1292+
wo->wo_stat = (exit_code << 8) | 0x7f;
13051293

13061294
infop = wo->wo_info;
13071295
if (infop) {
@@ -1310,9 +1298,6 @@ static int wait_task_stopped(struct wait_opts *wo,
13101298
infop->pid = pid;
13111299
infop->uid = uid;
13121300
}
1313-
put_task_struct(p);
1314-
1315-
BUG_ON(!pid);
13161301
return pid;
13171302
}
13181303

@@ -1324,7 +1309,7 @@ static int wait_task_stopped(struct wait_opts *wo,
13241309
*/
13251310
static int wait_task_continued(struct wait_opts *wo, struct task_struct *p)
13261311
{
1327-
int retval;
1312+
struct waitid_info *infop;
13281313
pid_t pid;
13291314
uid_t uid;
13301315

@@ -1351,18 +1336,18 @@ static int wait_task_continued(struct wait_opts *wo, struct task_struct *p)
13511336
sched_annotate_sleep();
13521337
if (wo->wo_rusage)
13531338
getrusage(p, RUSAGE_BOTH, wo->wo_rusage);
1339+
put_task_struct(p);
13541340

1355-
if (!wo->wo_info) {
1356-
put_task_struct(p);
1341+
infop = wo->wo_info;
1342+
if (!infop) {
13571343
wo->wo_stat = 0xffff;
1358-
retval = pid;
13591344
} else {
1360-
retval = wait_noreap_copyout(wo, p, pid, uid,
1361-
CLD_CONTINUED, SIGCONT);
1362-
BUG_ON(retval == 0);
1345+
infop->cause = CLD_CONTINUED;
1346+
infop->pid = pid;
1347+
infop->uid = uid;
1348+
infop->status = SIGCONT;
13631349
}
1364-
1365-
return retval;
1350+
return pid;
13661351
}
13671352

13681353
/*

0 commit comments

Comments
 (0)