| 591 | |
| 592 | static int _do_signal_wakeup(rt_thread_t thread, int sig); |
| 593 | static rt_err_t _stop_thread_locked(rt_lwp_t self_lwp, rt_thread_t cur_thr, int signo, |
| 594 | lwp_siginfo_t si, lwp_sigqueue_t sq) |
| 595 | { |
| 596 | rt_err_t error; |
| 597 | int jobctl_stopped = self_lwp->jobctl_stopped; |
| 598 | rt_thread_t iter; |
| 599 | |
| 600 | /* race to setup jobctl stopped flags */ |
| 601 | if (!jobctl_stopped) |
| 602 | { |
| 603 | self_lwp->jobctl_stopped = RT_TRUE; |
| 604 | self_lwp->wait_reap_stp = RT_FALSE; |
| 605 | rt_list_for_each_entry(iter, &self_lwp->t_grp, sibling) |
| 606 | { |
| 607 | if (iter != cur_thr) |
| 608 | _do_signal_wakeup(iter, signo); |
| 609 | } |
| 610 | } |
| 611 | |
| 612 | /** |
| 613 | * raise the event again so siblings is able to catch it again. |
| 614 | * `si` will be discarded while SIGCONT is generatd |
| 615 | */ |
| 616 | sigqueue_enqueue(sq, si); |
| 617 | |
| 618 | /* release the lwp lock so we can happily suspend */ |
| 619 | LWP_UNLOCK(self_lwp); |
| 620 | |
| 621 | rt_set_errno(RT_EOK); |
| 622 | |
| 623 | /* After suspension, only the SIGKILL and SIGCONT will wake this thread up */ |
| 624 | error = rt_thread_suspend_with_flag(cur_thr, RT_KILLABLE); |
| 625 | if (error == RT_EOK) |
| 626 | { |
| 627 | rt_schedule(); |
| 628 | error = rt_get_errno(); |
| 629 | error = error > 0 ? -error : error; |
| 630 | } |
| 631 | |
| 632 | if (!jobctl_stopped && |
| 633 | (sigqueue_ismember(_SIGQ(self_lwp), SIGCONT) || |
| 634 | sigqueue_ismember(_SIGQ(cur_thr), SIGCONT))) |
| 635 | { |
| 636 | /** |
| 637 | * if we are resumed by a SIGCONT and we are the winner of racing |
| 638 | * notify parent of the incoming event |
| 639 | */ |
| 640 | _notify_parent_and_leader(self_lwp, cur_thr, SIGCONT, RT_FALSE); |
| 641 | } |
| 642 | |
| 643 | /* reacquire the lock since we release it before */ |
| 644 | LWP_LOCK(self_lwp); |
| 645 | |
| 646 | return error; |
| 647 | } |
| 648 | |
| 649 | static void _catch_signal_locked(rt_lwp_t lwp, rt_thread_t thread, int signo, |
| 650 | lwp_siginfo_t siginfo, lwp_sighandler_t handler, |
no test coverage detected