Xenomai API
2.6.5
|
Signals management services. More...
Functions | |
int | sigemptyset (sigset_t *set) |
Initialize and empty a signal set. More... | |
int | sigfillset (sigset_t *set) |
Initialize and fill a signal set. More... | |
int | sigaddset (sigset_t *set, int sig) |
Add a signal to a signal set. More... | |
int | sigdelset (sigset_t *set, int sig) |
Delete a signal from a signal set. More... | |
int | sigismember (const sigset_t *set, int sig) |
Test for a signal in a signal set. More... | |
int | sigaction (int sig, const struct sigaction *act, struct sigaction *oact) |
Examine and change a signal action. More... | |
int | pthread_kill (pthread_t thread, int sig) |
Send a signal to a thread. More... | |
int | pthread_sigqueue_np (pthread_t thread, int sig, union sigval value) |
Queue a signal to a thread. More... | |
int | sigpending (sigset_t *set) |
Examine pending signals. More... | |
int | pthread_sigmask (int how, const sigset_t *set, sigset_t *oset) |
Examine and change the set of signals blocked by a thread. More... | |
int | sigwait (const sigset_t *set, int *sig) |
Wait for signals. More... | |
int | sigwaitinfo (const sigset_t *__restrict__ set, siginfo_t *__restrict__ info) |
Wait for signals. More... | |
int | sigtimedwait (const sigset_t *__restrict__ set, siginfo_t *__restrict__ info, const struct timespec *__restrict__ timeout) |
Wait during a bounded time for signals. More... | |
Signals management services.
Signals are asynchronous notifications delivered to a process or thread. Such notifications occur as the result of an exceptional event or at the request of another process.
The services documented here are reserved to Xenomai kernel-space threads, user-space threads switch to secondary mode when handling signals, and use Linux regular signals services.
Xenomai POSIX skin signals are implemented as real-time signals, meaning that they are queued when posted several times to a thread before the first notification is handled, and that each signal carry additional data in a siginfo_t object. In order to ensure consistence with user-space signals, valid signals number range from 1 to SIGRTMAX, signals from SIGRTMIN to SIGRTMAX being higher priority than signals from 1 to SIGRTMIN-1. As a special case, signal 0 may be used with services pthread_kill() and pthread_sigqueue_np() to check if a thread exists, but entails no other action.
The action to be taken upon reception of a signal depends on the thread signal mask, (see pthread_sigmask()), and on the settings described by a sigaction structure (see sigaction()).
int pthread_kill | ( | pthread_t | thread, |
int | sig | ||
) |
Send a signal to a thread.
This service send the signal sig to the Xenomai POSIX skin thread thread (created with pthread_create()). If sig is zero, this service check for existence of the thread thread, but no signal is sent.
thread | thread identifier; |
sig | signal number. |
References XNBREAK, xnpod_resume_thread(), xnpod_schedule(), xnpod_suspend_thread(), xnpod_unblock_thread(), and XNSUSP.
int pthread_sigmask | ( | int | how, |
const sigset_t * | set, | ||
sigset_t * | oset | ||
) |
Examine and change the set of signals blocked by a thread.
The signal mask of a thread is the set of signals that are blocked by this thread.
If oset is not NULL, this service stores, at the address oset the current signal mask of the calling thread.
If set is not NULL, this service sets the signal mask of the calling thread according to the value of how, as follow:
If some signals are unblocked by this service, they are handled before this service returns.
how | if set is not null, a value indicating how to interpret set; |
set | if not null, a signal set that will be used to modify the calling thread signal mask; |
oset | if not null, address where the previous value of the calling thread signal mask will be stored on success. |
References xnpod_schedule().
int pthread_sigqueue_np | ( | pthread_t | thread, |
int | sig, | ||
union sigval | value | ||
) |
Queue a signal to a thread.
This service send the signal sig to the Xenomai POSIX skin thread thread (created with pthread_create()), with the value value. If sig is zero, this service check for existence of the thread thread, but no signal is sent.
This service is equivalent to the POSIX service sigqueue(), except that the signal is directed to a thread instead of being directed to a process.
thread | thread identifier, |
sig | signal number, |
value | additional datum passed to thread with the signal sig. |
References xnpod_schedule().
int sigaction | ( | int | sig, |
const struct sigaction * | act, | ||
struct sigaction * | oact | ||
) |
Examine and change a signal action.
The sigaction structure descibes the actions to be taken upon signal delivery. A sigaction structure is associated with every signal, for the kernel-space as a whole.
If oact is not NULL, this service returns at the address oact, the current value of the sigaction structure associated with the signal sig.
If act is not NULL, this service set to the value pointed to by act, the sigaction structure associated with the signal sig.
The structure sigaction has the following members:
When using sa_handler as a signal handler, it is passed the number of the received signal, when using sa_sigaction, two additional arguments are passed:
The following members of the siginfo_t structure are filled by this implementation:
sig | a signal number; |
act | if not null, description of the action to be taken upon notification of the signal sig; |
oact | if not null, address where the previous description of the signal action is stored on success. |
0 | on sucess; |
-1 | with errno set if:
|
int sigaddset | ( | sigset_t * | set, |
int | sig | ||
) |
Add a signal to a signal set.
This service adds the signal number sig to the signal set pointed to by set.
set | address of a signal set; |
sig | signal to be added to set. |
0 | on success; |
-1 | with errno set if:
|
int sigdelset | ( | sigset_t * | set, |
int | sig | ||
) |
Delete a signal from a signal set.
This service remove the signal number sig from the signal set pointed to by set.
set | address of a signal set; |
sig | signal to be removed from set. |
0 | on success; |
-1 | with errno set if:
|
int sigemptyset | ( | sigset_t * | set | ) |
Initialize and empty a signal set.
This service initializes ane empties the signal set pointed to by set.
set | address of a the signal set to be initialized. |
0 |
int sigfillset | ( | sigset_t * | set | ) |
Initialize and fill a signal set.
This service initializes ane fills the signal set pointed to by set.
set | address of a the signal set to be filled. |
0 |
int sigismember | ( | const sigset_t * | set, |
int | sig | ||
) |
Test for a signal in a signal set.
This service tests whether the signal number sig is member of the signal set pointed to by set.
set | address of a signal set; |
sig | tested signal number. |
0 | on success; |
-1 | with errno set if:
|
int sigpending | ( | sigset_t * | set | ) |
Examine pending signals.
This service stores, at the address set, the set of signals that are currently blocked and have been received by the calling thread.
set | address where the set of blocked and received signals are stored on success. |
0 | on success; |
-1 | with errno set if:
|
int sigtimedwait | ( | const sigset_t *__restrict__ | set, |
siginfo_t *__restrict__ | info, | ||
const struct timespec *__restrict__ | timeout | ||
) |
Wait during a bounded time for signals.
This service is equivalent to the sigwaitinfo() service, except that the calling thread is only blocked until the timeout specified by timeout expires.
set | set of signals to wait for; |
info | address where the received siginfo_t object will be stored on success; |
timeout | the timeout, expressed as a time interval. |
0 | on success; |
-1 | with errno set if:
|
int sigwait | ( | const sigset_t * | set, |
int * | sig | ||
) |
Wait for signals.
This service blocks a Xenomai kernel-space POSIX skin thread until a signal of the set set is received. If a signal in set is not currently blocked by the calling thread, this service returns immediately with an error. The signal received is stored at the address sig.
If a signal of the set set was already pending, it is cleared and this service returns immediately.
Signals are received in priority order, i.e. from SIGRTMIN to SIGRTMAX, then from 1 to SIGRTMIN-1.
set | set of signals to wait for; |
sig | address where the received signal will be stored on success. |
int sigwaitinfo | ( | const sigset_t *__restrict__ | set, |
siginfo_t *__restrict__ | info | ||
) |
Wait for signals.
This service is equivalent to the sigwait() service, except that it returns, at the address info, the siginfo_t object associated with the received signal instead of only returning the signal number.
set | set of signals to wait for; |
info | address where the received siginfo_t object will be stored on success. |
0 | on success; |
-1 | with errno set if:
|