man sigaction () - RTLinux POSIX signal handling functions

NAME

sigaction - RTLinux POSIX signal handling functions

SYNOPSIS

#include <posix/signal.h> 
 
int sigaction(int signum, const struct sigaction *act, struct sigaction *oldact); 
 
int  sigprocmask(int  how,  const  sigset_t *set, sigset_t *oldset); 

DESCRIPTION

Signals interactions with pthreads is one of the less well defined and most contentious parts of POSIX. Many problems come from the interaction between process signals and thread signals. RTLinux V3.0 uses the concept of process signals to provide an interface to hard interrupt handlers. The signals RTL_SIGIRQMIN to RTL_SIGIRQMIN + NR_IRQS refer to global hardware interrupts, and installing signal handlers is the same as installing interrupt handlers.

RTLinux provides the POSIX sigaction function to install handlers for hardware interrupts and also to provide POSIX signaling (this is incomplete in V3.0).

signum specifies the signal and can be any valid signal except SIGKILL and SIGSTOP.

If act is non-null, the new action for signal signum is installed from act. If oldact is non-null, the previous action is saved in oldact.

The sigaction structure is defined as

CW       struct sigaction{ 
void (*sa_handler)(int); 
sigset_t sa_mask; 
int sa_flags; 
void (*sa_restorer)(void); 
unsigned int sa_focus; 
} 

The sa_focus field is an RTLinux-specific extension that is a bit map defining which processors on an SMP system can accept these interrupts. This is machine-specific and may only be used for hardware interrupts using the RTL_SIGIRQMIN+n, to catch hardware interrupt n.

sa_handler specifies the action to be associated with signum and may be SIG_DFL for the default action, SIG_IGN to ignore this signal, or a pointer to a signal handling function.

sa_mask gives a mask of signals which should be blocked during execution of the signal handler. In addition, the signal which triggered the handler will be blocked, unless the SA_NODEFER or SA_NOMASK flags are used. In V3 and prior RTLinux these flags have no effect. Furthermore, when a signal handler for a hard interrupt is entered all interrupts are blocked by default.

sa_flags specifies a set of flags which modify the behaviour of the signal handling process. In RTLinux V3.0 and earlier these flags are ignored.

The sa_focus element is used to direct a hardware interrupt to a particular set of processors in an SMP system. This element has no effiect on soft-interrupts, on processor-specific interrupts (e.g. local timers and IPIs), on uni-processor systems, or where the interrupt control logic does not support interrupt focus.

The sigprocmask call is used to change the list of currently blocked signals in a single threaded process. POSIX states that the sigprocmask call has undefined operation in a multi-threaded process. In RTLinux, if the pthreads-based scheduling module (rtl_sched) is loaded or otherwise activated, the RT process is multithreaded and sigprocmask behavior undefined, unless the ``how'' variable is set to SIG_DISABLE or SIG_ENABLE. These two flags are RTLinux extensions. The behaviour of the call is dependent on the value of how, as follows.

SIG_BLOCK
The set of blocked signals is the union of the current set and the set argument.
SIG_UNBLOCK
The signals in set are removed from the current set of blocked signals. It is legal to attempt to unblock a signal which is not blocked.
SIG_SETMASK
The set of blocked signals is set to the argument set.
SIG_DISABLE
Turns on local processor interrupts.
SIG_ENABLE
Turns on local processor interrupts.

Note that in RTLinux, as in POSIX, not all signals can be masked or blocked.

If oldset is non-null, the previous value of the signal mask is stored in oldset.

RETURN VALUES

sigaction, sigprocmask, sigpending and sigsuspend return 0 on success and -1 on error.

ERRORS

EINVAL
An invalid signal was specified. This will also be generated if an attempt is made to change the action for SIGKILL or SIGSTOP, which cannot be caught.
EFAULT
act,oldact, set or oldset point to memory which is not a valid part of the process address space.
EINTR
System call was interrupted. This cannot happen in RTLinux V3.0 or prior.

NOTES

It is not possible to block SIGKILL or SIGSTOP with the sigprocmask call. Attempts to do so will be silently ignored. RTLinux also adds an additional set of unmaskable and uncatchable signals.

According to POSIX, the behaviour of a process is undefined after it ignores a SIGFPE, SIGILL, or SIGSEGV signal that was not generated by the kill() or the raise() functions. Integer division by zero has undefined result. On some architectures it will generate a SIGFPE signal. (Also, dividing the most negative integer by -1 may generate SIGFPE.) Ignoring this signal might lead to an endless loop.

SIGCHLD cannot happen in V3.0 RTLinux or prior, since there is no way to create child processes.

The POSIX spec only defines SA_NOCLDSTOP. Use of other sa_flags is non-portable.

sigaction can be called with a null second argument to query the current signal handler. It can also be used to check whether a given signal is valid for the current machine, by calling it with null second and third arguments.

SEE ALSO

UNIX spec sigaction (link to URL ../susv2/xsh/sigaction.html) , UNIX spec kill(2) (link to URL ../susv2/xsh/kill.html)

©2001 FSMLabs Inc.

All rights reserved.