@@ -1057,22 +1057,6 @@ eligible_child(struct wait_opts *wo, bool ptrace, struct task_struct *p)
1057
1057
return 1 ;
1058
1058
}
1059
1059
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
-
1076
1060
/*
1077
1061
* Handle sys_wait4 work for one task in state EXIT_ZOMBIE. We hold
1078
1062
* 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)
1091
1075
1092
1076
if (unlikely (wo -> wo_flags & WNOWAIT )) {
1093
1077
int exit_code = p -> exit_code ;
1094
- int why ;
1095
1078
1096
1079
get_task_struct (p );
1097
1080
read_unlock (& tasklist_lock );
1098
1081
sched_annotate_sleep ();
1099
1082
if (wo -> wo_rusage )
1100
1083
getrusage (p , RUSAGE_BOTH , wo -> wo_rusage );
1084
+ put_task_struct (p );
1101
1085
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 ;
1108
1097
}
1109
- return wait_noreap_copyout ( wo , p , pid , uid , why , status ) ;
1098
+ return pid ;
1110
1099
}
1111
1100
/*
1112
1101
* 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,
1297
1286
sched_annotate_sleep ();
1298
1287
if (wo -> wo_rusage )
1299
1288
getrusage (p , RUSAGE_BOTH , wo -> wo_rusage );
1289
+ put_task_struct (p );
1300
1290
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 ;
1305
1293
1306
1294
infop = wo -> wo_info ;
1307
1295
if (infop ) {
@@ -1310,9 +1298,6 @@ static int wait_task_stopped(struct wait_opts *wo,
1310
1298
infop -> pid = pid ;
1311
1299
infop -> uid = uid ;
1312
1300
}
1313
- put_task_struct (p );
1314
-
1315
- BUG_ON (!pid );
1316
1301
return pid ;
1317
1302
}
1318
1303
@@ -1324,7 +1309,7 @@ static int wait_task_stopped(struct wait_opts *wo,
1324
1309
*/
1325
1310
static int wait_task_continued (struct wait_opts * wo , struct task_struct * p )
1326
1311
{
1327
- int retval ;
1312
+ struct waitid_info * infop ;
1328
1313
pid_t pid ;
1329
1314
uid_t uid ;
1330
1315
@@ -1351,18 +1336,18 @@ static int wait_task_continued(struct wait_opts *wo, struct task_struct *p)
1351
1336
sched_annotate_sleep ();
1352
1337
if (wo -> wo_rusage )
1353
1338
getrusage (p , RUSAGE_BOTH , wo -> wo_rusage );
1339
+ put_task_struct (p );
1354
1340
1355
- if (! wo -> wo_info ) {
1356
- put_task_struct ( p );
1341
+ infop = wo -> wo_info ;
1342
+ if (! infop ) {
1357
1343
wo -> wo_stat = 0xffff ;
1358
- retval = pid ;
1359
1344
} 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 ;
1363
1349
}
1364
-
1365
- return retval ;
1350
+ return pid ;
1366
1351
}
1367
1352
1368
1353
/*
0 commit comments