MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / _reap_any_child_pid

Function _reap_any_child_pid

components/lwp/lwp_pid.c:1312–1340  ·  view source on GitHub ↗

* @brief Reaps any child process with given pair_pgid that has terminated or stopped * * @param[in] cur_thr Current thread context * @param[in] self_lwp Parent process (current LWP) * @param[in] pair_pgid Process group ID to match (0 for any) * @param[in] options Wait options (e.g., WNOHANG) * @param[out] ustatus Pointer to store child's exit status (optional) * @param[in,out] uru Pointer t

Source from the content-addressed store, hash-verified

1310 * @note Iterates through child processes to find one that matches given pair_pgid
1311 */
1312static pid_t _reap_any_child_pid(rt_thread_t cur_thr, rt_lwp_t self_lwp, pid_t pair_pgid,
1313 int options, int *ustatus, struct rusage *uru)
1314{
1315 sysret_t rc = -ECHILD;
1316 struct rt_lwp *child;
1317
1318 LWP_LOCK(self_lwp);
1319 child = self_lwp->first_child;
1320
1321 /* find a exited child if any */
1322 while (child)
1323 {
1324 if (pair_pgid && child->pgid != pair_pgid)
1325 continue;
1326
1327 rc = _query_event_from_lwp(child, cur_thr, self_lwp, options, ustatus);
1328 if (rc > 0)
1329 break;
1330
1331 child = child->sibling;
1332 }
1333 LWP_UNLOCK(self_lwp);
1334
1335 if (rc > 0)
1336 {
1337 _stats_and_reap_child(child, cur_thr, self_lwp, ustatus, options, uru);
1338 }
1339 return rc;
1340}
1341
1342/**
1343 * @brief Wakes up processes waiting for a child process status change

Callers 1

lwp_waitpidFunction · 0.85

Calls 2

_query_event_from_lwpFunction · 0.85
_stats_and_reap_childFunction · 0.85

Tested by

no test coverage detected