RT-Thread RTOS
An open source embedded real-time operating system
+ Collaboration diagram for Signal:

Functions

void rt_signal_mask (int signo)
 
void rt_signal_unmask (int signo)
 
rt_sighandler_t rt_signal_install (int signo, rt_sighandler_t handler)
 
int rt_signal_wait (const rt_sigset_t *set, rt_siginfo_t *si, rt_int32_t timeout)
 

Detailed Description

signal is used for thread kill etc.

A signal (also known as a soft interrupt signal), from a software perspective, is a simulation of interrupt mechanism. When it comes to its principle, thread receiving a signal is similar to processor receiving an interrupt request.

Function Documentation

◆ rt_signal_mask()

void rt_signal_mask ( int  signo)

This function will block the specified signal.

Note
This function will block the specified signal, even if the rt_thread_kill() function is called to send this signal to the current thread, it will no longer take effect.
See also
rt_thread_kill()
Parameters
signois a specific signal value (range: 0 ~ RT_SIG_MAX).

◆ rt_signal_unmask()

void rt_signal_unmask ( int  signo)

This function will unblock the specified signal.

Note
This function will unblock the specified signal. After calling the rt_thread_kill() function to send this signal to the current thread, it will take effect.
See also
rt_thread_kill()
Parameters
signois a specific signal value (range: 0 ~ RT_SIG_MAX).

◆ rt_signal_install()

rt_sighandler_t rt_signal_install ( int  signo,
rt_sighandler_t  handler 
)

This function will install a processing function to a specific signal and return the old processing function of this signal.

Note
This function needs to be used in conjunction with the rt_signal_unmask() function to make the signal effective.
See also
rt_signal_unmask()
Parameters
signois a specific signal value (range: 0 ~ RT_SIG_MAX).
handleris sets the processing of signal value.
Returns
Return the old processing function of this signal. ONLY When the return value is SIG_ERR, the operation is failed.

◆ rt_signal_wait()

int rt_signal_wait ( const rt_sigset_t *  set,
rt_siginfo_t *  si,
rt_int32_t  timeout 
)

This function will wait for the arrival of the set signal. If it does not wait for this signal, the thread will be suspended until it waits for this signal or the waiting time exceeds the specified timeout: timeout.

Parameters
setis the set of signal values to be waited for. Use the function sigaddset() to add the signal.
siis a pointer to the received signal info. If you don't care about this value, you can use RT_NULL to set.
timeoutis a timeout period (unit: an OS tick).
Returns
Return the operation status. When the return value is RT_EOK, the operation is successful. If the return value is any other values, it means that the signal wait failed.