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

Function sys_sigtimedwait

components/lwp/lwp_syscall.c:6680–6745  ·  view source on GitHub ↗

* @brief Waits for a signal to be delivered, with a timeout. * * This system call allows a process to wait for one of the signals specified in the `sigset` to be delivered. * The process will block until a signal in the set is received or the specified timeout period expires. * If the signal is received before the timeout, information about the signal will be returned in the `siginfo_t` struct

Source from the content-addressed store, hash-verified

6678 * @see sys_sigaction(), sys_sigtimedwait()
6679 */
6680sysret_t sys_sigtimedwait(const sigset_t *sigset, siginfo_t *info, const struct timespec *timeout, size_t sigsize)
6681{
6682 int sig;
6683 size_t ret;
6684 lwp_sigset_t lwpset;
6685 siginfo_t kinfo;
6686 struct timespec ktimeout;
6687 struct timespec *ptimeout;
6688
6689 /* for RT_ASSERT */
6690 RT_UNUSED(ret);
6691
6692 /* Fit sigset size to lwp set */
6693 if (sizeof(lwpset) < sigsize)
6694 {
6695 LOG_I("%s: sigsize (%lx) extends lwp sigset chunk\n", __func__, sigsize);
6696 sigsize = sizeof(lwpset);
6697 }
6698 else
6699 {
6700 /* if sigset of user is smaller, clear extra space */
6701 memset(&lwpset, 0, sizeof(lwpset));
6702 }
6703
6704 /* Verify and Get sigset, timeout */
6705 if (!sigset || !lwp_user_accessable((void *)sigset, sigsize))
6706 {
6707 return -EFAULT;
6708 }
6709 else
6710 {
6711 ret = lwp_get_from_user(&lwpset, (void *)sigset, sigsize);
6712 RT_ASSERT(ret == sigsize);
6713 }
6714
6715 if (timeout)
6716 {
6717 if (!lwp_user_accessable((void *)timeout, sizeof(*timeout)))
6718 return -EFAULT;
6719 else
6720 {
6721 ret = lwp_get_from_user(&ktimeout, (void *)timeout, sizeof(*timeout));
6722 ptimeout = &ktimeout;
6723 RT_ASSERT(ret == sizeof(*timeout));
6724 }
6725 }
6726 else
6727 {
6728 ptimeout = RT_NULL;
6729 }
6730
6731 sig = lwp_thread_signal_timedwait(rt_thread_self(), &lwpset, &kinfo, ptimeout);
6732
6733 if (sig > 0 && info)
6734 {
6735 if (!lwp_user_accessable((void *)info, sizeof(*info)))
6736 return -EFAULT;
6737 else

Callers

nothing calls this directly

Calls 5

lwp_user_accessableFunction · 0.85
lwp_get_from_userFunction · 0.85
rt_thread_selfFunction · 0.85
lwp_put_to_userFunction · 0.85

Tested by

no test coverage detected