* @brief Notifies parent process about child process termination * * @param[in,out] lwp The child lightweight process structure * * @note This function sends SIGCHLD signal to parent process with termination details. * It handles both signaled (killed/dumped) and normal exit cases. */
| 2083 | * It handles both signaled (killed/dumped) and normal exit cases. |
| 2084 | */ |
| 2085 | static void _notify_parent(rt_lwp_t lwp) |
| 2086 | { |
| 2087 | int si_code; |
| 2088 | int signo_or_exitcode; |
| 2089 | lwp_siginfo_ext_t ext; |
| 2090 | lwp_status_t lwp_status = lwp->lwp_status; |
| 2091 | rt_lwp_t parent = lwp->parent; |
| 2092 | |
| 2093 | if (WIFSIGNALED(lwp_status)) |
| 2094 | { |
| 2095 | si_code = (lwp_status & LWP_COREDUMP_FLAG) ? CLD_DUMPED : CLD_KILLED; |
| 2096 | signo_or_exitcode = WTERMSIG(lwp_status); |
| 2097 | } |
| 2098 | else |
| 2099 | { |
| 2100 | si_code = CLD_EXITED; |
| 2101 | signo_or_exitcode = WEXITSTATUS(lwp->lwp_status); |
| 2102 | } |
| 2103 | |
| 2104 | lwp_waitpid_kick(parent, lwp); |
| 2105 | |
| 2106 | ext = rt_malloc(sizeof(struct lwp_siginfo)); |
| 2107 | |
| 2108 | if (ext) |
| 2109 | { |
| 2110 | rt_thread_t cur_thr = rt_thread_self(); |
| 2111 | ext->sigchld.status = signo_or_exitcode; |
| 2112 | ext->sigchld.stime = cur_thr->system_time; |
| 2113 | ext->sigchld.utime = cur_thr->user_time; |
| 2114 | } |
| 2115 | lwp_signal_kill(parent, SIGCHLD, si_code, ext); |
| 2116 | } |
| 2117 | |
| 2118 | /** |
| 2119 | * @brief Clean up resources when a lightweight process (LWP) terminates |
no test coverage detected