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

Function lwp_thread_signal_kill

components/lwp/lwp_signal.c:1193–1252  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1191}
1192
1193rt_err_t lwp_thread_signal_kill(rt_thread_t thread, long signo, long code, lwp_siginfo_ext_t value)
1194{
1195 rt_err_t ret = -1;
1196
1197 struct rt_lwp *lwp;
1198 lwp_siginfo_t siginfo;
1199 rt_bool_t need_schedule;
1200
1201 /** must be able to be suspended */
1202 RT_DEBUG_SCHEDULER_AVAILABLE(RT_TRUE);
1203
1204 LOG_D("%s(signo=%d)", __func__, signo);
1205
1206 if (!thread || signo < 0 || signo >= _LWP_NSIG)
1207 {
1208 ret = -RT_EINVAL;
1209 }
1210 else if (signo == 0)
1211 {
1212 /* thread exist and current thread have privileges */
1213 ret = 0;
1214 }
1215 else
1216 {
1217 lwp = thread->lwp;
1218 need_schedule = RT_FALSE;
1219
1220 RT_ASSERT(lwp);
1221
1222 LWP_LOCK(lwp);
1223
1224 if (!lwp)
1225 ret = -RT_EPERM;
1226 else if (lwp->terminated || _sighandler_is_ignored(lwp, signo))
1227 ret = 0;
1228 else
1229 {
1230 siginfo = siginfo_create(rt_thread_self(), signo, code, value);
1231
1232 if (siginfo)
1233 {
1234 need_schedule = _siginfo_deliver_to_thread(thread, siginfo);
1235 lwp_signal_notify(&lwp->signalfd_notify_head, siginfo);
1236 ret = 0;
1237 }
1238 else
1239 {
1240 LOG_I("%s: siginfo malloc failed", __func__);
1241 ret = -RT_ENOMEM;
1242 }
1243 }
1244
1245 LWP_UNLOCK(lwp);
1246
1247 if (need_schedule)
1248 rt_schedule();
1249 }
1250

Callers 2

sys_tkillFunction · 0.85

Calls 6

_sighandler_is_ignoredFunction · 0.85
siginfo_createFunction · 0.85
rt_thread_selfFunction · 0.85
lwp_signal_notifyFunction · 0.85
rt_scheduleFunction · 0.50

Tested by

no test coverage detected