| 989 | } |
| 990 | |
| 991 | rt_err_t lwp_signal_kill(struct rt_lwp *lwp, long signo, long code, lwp_siginfo_ext_t value) |
| 992 | { |
| 993 | rt_err_t ret = -1; |
| 994 | |
| 995 | lwp_siginfo_t siginfo; |
| 996 | rt_bool_t terminated; |
| 997 | rt_bool_t need_schedule; |
| 998 | |
| 999 | /** must be able to be suspended */ |
| 1000 | RT_DEBUG_SCHEDULER_AVAILABLE(RT_TRUE); |
| 1001 | |
| 1002 | if (!lwp || signo < 0 || signo > _LWP_NSIG) |
| 1003 | { |
| 1004 | ret = -RT_EINVAL; |
| 1005 | } |
| 1006 | else if (signo == 0) |
| 1007 | { |
| 1008 | /* process exist and current process have privileges */ |
| 1009 | ret = 0; |
| 1010 | } |
| 1011 | else |
| 1012 | { |
| 1013 | LOG_D("%s(lwp=%p \"%s\",signo=%ld,code=%ld,value=%ld)", |
| 1014 | __func__, lwp, lwp->cmd, signo, code, value); |
| 1015 | |
| 1016 | need_schedule = RT_FALSE; |
| 1017 | |
| 1018 | LWP_LOCK(lwp); |
| 1019 | terminated = lwp->terminated; |
| 1020 | |
| 1021 | /* short-circuit code for inactive task, ignored signals */ |
| 1022 | if (terminated) |
| 1023 | { |
| 1024 | /* no one rely on this, then free the resource */ |
| 1025 | if (value) |
| 1026 | rt_free(value); |
| 1027 | ret = 0; |
| 1028 | } |
| 1029 | else |
| 1030 | { |
| 1031 | siginfo = siginfo_create(rt_thread_self(), signo, code, value); |
| 1032 | |
| 1033 | if (siginfo) |
| 1034 | { |
| 1035 | if (_is_jobctl_signal(lwp, signo)) |
| 1036 | _before_sending_jobctl_signal(signo, lwp, siginfo); |
| 1037 | |
| 1038 | need_schedule = _siginfo_deliver_to_lwp(lwp, siginfo); |
| 1039 | lwp_signal_notify(&lwp->signalfd_notify_head, siginfo); |
| 1040 | ret = 0; |
| 1041 | } |
| 1042 | else |
| 1043 | { |
| 1044 | LOG_I("%s: siginfo malloc failed", __func__); |
| 1045 | ret = -RT_ENOMEM; |
| 1046 | } |
| 1047 | } |
| 1048 |
no test coverage detected