| You are here: | About>Computing & Technology>Focus on Linux |
![]() | Focus on Linux |
NAMEsigaction, sigprocmask, sigpending, sigsuspend - POSIX signal handling functions.SYNOPSIS#include <signal.h>int sigaction(int signum, const struct sigaction *act, struct sigaction *oldact); int sigprocmask(int how, const sigset_t *set, sigset_t *oldset); int sigpending(sigset_t *set); int sigsuspend(const sigset_t *mask); DESCRIPTIONThe sigaction system call is used to change the action taken by a process on receipt of a specific signal.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 something like
On some architectures a union is involved - do not assign to both sa_handler and sa_sigaction. The sa_restorer element is obsolete and should not be used. POSIX does not specify a sa_restorer element. 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. sa_flags specifies a set of flags which modify the behaviour of the signal handling process. It is formed by the bitwise OR of zero or more of the following:
The siginfo_t parameter to sa_sigaction is a struct with the following elements
si_signo, si_errno and si_code are defined for all signals. The rest of the struct may be a union, so that one should only read the fields that are meaningful for the given signal. kill(2), POSIX.1b signals and SIGCHLD fill in si_pid and si_uid. SIGCHLDalsofillsin si_status, si_utime and si_stime. si_int and si_ptr are specified by the sender of the POSIX.1b signal. SIGILL, SIGFPE, SIGSEGV and SIGBUS fill in si_addr with the address of the fault. SIGPOLL fills in si_band and si_fd. si_code indicates why this signal was sent. It is a value, not a bitmask. The values which are possible for any signal are listed in this table:
The sigprocmask call is used to change the list of currently blocked signals. The behaviour of the call is dependent on the value of how, as follows.
If oldset is non-null, the previous value of the signal mask is stored in oldset. The sigpending call allows the examination of pending signals (ones which have been raised while blocked). The signal mask of pending signals is stored in set. The sigsuspend call temporarily replaces the signal mask for the process with that given by mask and then suspends the process until a signal is received. RETURN VALUEThe functions sigaction, sigprocmask, and sigpending return 0 on success and -1 on error. The function sigsuspend always returns -1, normally with the error EINTR.ERRORS
SEE ALSOkill(1), kill(2), killpg(2), pause(2), sigaltstack(2), raise(3), siginterrupt(3), signal(2), signal(7), sigsetops(3), sigvec(2)
Important: Use the man command (% man) to see how a command is used on your particular computer. |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
All Topics | Email Article | | | ![]() |
| Advertising Info | News & Events | Work at About | SiteMap | Reprints | Help | Our Story | Be a Guide |
| User Agreement | Ethics Policy | Patent Info. | Privacy Policy | ©2008 About, Inc., A part of The New York Times Company. All rights reserved. |


