Penguin

Differences between version 3 and predecessor to the previous major change of sigaction(2).

Other diffs: Previous Revision, Previous Author, or view the Annotated Edit History

Newer page: version 3 Last edited on Sunday, February 23, 2003 2:35:51 pm by PerryLorier Revert
Older page: version 2 Last edited on Friday, October 18, 2002 12:02:03 am by PerryLorier Revert
@@ -1,317 +1,137 @@
-SIGACTION  
-!!!SIGACTION  
-!!NAME  
-  
-  
 sigaction, sigprocmask, sigpending, sigsuspend - POSIX signal handling functions. 
  
 !!SYNOPSIS 
  
-__int sigaction(int__ ''signum''__, const struct  
- sigaction *__''act''__, struct sigaction  
- *__''oldact''__);__  
-  
-  
-__int sigprocmask(int__ ''how''__, const sigset_t  
-*__''set''__, sigset_t  
-*__''oldset ''__);__ 
+__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 sigpending(sigset_t *__''set''__);__ 
  
+__int sigsuspend(const sigset_t *__''mask''__);__  
  
-__int sigsuspend(const sigset_t  
-*__''mask''__);__  
 !!DESCRIPTION 
-  
 See, UnixSignals 
  
+The __sigaction__ system call is used to change the action taken by a process on receipt of a specific signal.  
  
-The __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__ .  
-  
+''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 
+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  
  
-The __sigaction__ structure is defined as something  
-like  
+ struct sigaction {  
+ void (*sa _handler)(int);  
+ void (*sa _sigaction)(int, siginfo _t *, void *);  
+ sigset_t sa_mask;  
+ int sa_flags;  
+ void (*sa _restorer)(void);  
+ }  
  
+On some architectures a union is involved - do not assign to both ''sa_handler'' and ''sa_sigaction''.  
  
-struct sigaction {  
-void (* sa_handler)(int);  
-void (*sa_sigaction)(int, siginfo_t *, void *);  
-sigset_t sa_mask;  
-int sa_flags;  
-void (* sa_restorer)(void);  
-}  
+The '' sa_restorer'' element is obsolete and should not be used. POSIX does not specify a '' sa_restorer'' element.  
  
-  
-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 
+''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_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 
+''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: 
  
+;__SA_NOCLDSTOP__: If ''signum'' is __SIGCHLD__, do not receive notification when child processes stop (i.e., when child processes receive one of [SIGSTOP], [SIGTSTP], [SIGTTIN] or [SIGTTOU]).  
  
-__SA_NOCLDSTOP __ 
+; __SA_ONESHOT __ or __SA_RESETHAND__; Restore the signal action to the default state once the signal handler has been called. (This is the default behavior of the signal(2) system call.)  
  
+;__SA_RESTART__: Provide behaviour compatible with BSD signal semantics by making certain system calls restartable across signals.  
  
-If ''signum'' is __SIGCHLD __, do not receive  
-notification when child processes stop (i.e., when child  
-processes receive one of __SIGSTOP __, __SIGTSTP__,  
-__SIGTTIN__ or __SIGTTOU__)
+; __SA _NOMASK __ or __SA _NODEFER __: Do not prevent the signal from being received from within its own signal handler
  
+;__SA_SIGINFO__: The signal handler takes 3 arguments, not one. In this case, ''sa_sigaction'' should be set instead of ''sa_handler''. (The sa_sigaction field was added in Linux 2.1.86.)  
  
-__SA_ONESHOT__ or __SA_RESETHAND__  
+The ''siginfo _t'' parameter to ''sa _sigaction'' is a struct with the following elements  
  
+ siginfo_t {  
+ int si_signo; /* Signal number */  
+ int si_errno; /* An errno value */  
+ int si_code; /* Signal code */  
+ pid_t si_pid; /* Sending process ID */  
+ uid_t si_uid; /* Real user ID of sending process */  
+ int si_status; /* Exit value or signal */  
+ clock_t si_utime; /* User time consumed */  
+ clock_t si_stime; /* System time consumed */  
+ sigval_t si_value; /* Signal value */  
+ int si_int; /* POSIX.1b signal */  
+ void * si_ptr; /* POSIX.1b signal */  
+ void * si_addr; /* Memory location which caused fault */  
+ int si_band; /* Band event */  
+ int si_fd; /* File descriptor */  
+ }  
  
-Restore the signal action to the default state once the  
-signal handler has been called. (This is the default  
-behavior of the signal(2) system call.)  
-  
-  
-__SA_RESTART__  
-  
-  
-Provide behaviour compatible with BSD signal semantics by  
-making certain system calls restartable across  
-signals.  
-  
-  
-__SA_NOMASK__ or __SA_NODEFER__  
-  
-  
-Do not prevent the signal from being received from within  
-its own signal handler.  
-  
-  
-__SA_SIGINFO__  
-  
-  
-The signal handler takes 3 arguments, not one. In this case,  
-''sa_sigaction'' should be set instead of  
-''sa_handler''. (The sa_sigaction field was added in  
-Linux 2.1.86.)  
-  
-  
-The ''siginfo_t'' parameter to ''sa_sigaction'' is a  
-struct with the following elements  
-  
-  
-siginfo_t {  
-int si_signo; /* Signal number */  
-int si_errno; /* An errno value */  
-int si_code; /* Signal code */  
-pid_t si_pid; /* Sending process ID */  
-uid_t si_uid; /* Real user ID of sending process */  
-int si_status; /* Exit value or signal */  
-clock_t si_utime; /* User time consumed */  
-clock_t si_stime; /* System time consumed */  
-sigval_t si_value; /* Signal value */  
-int si_int; /* POSIX.1b signal */  
-void * si_ptr; /* POSIX.1b signal */  
-void * si_addr; /* Memory location which caused fault */  
-int si_band; /* Band event */  
-int si_fd; /* File descriptor */  
-}  
-  
-  
- ''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''.  
- SIGCHLD also fills in ''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:  
+''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''. SIGCHLD also fills in ''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. 
  
+;__SIG_BLOCK__: The set of blocked signals is the union of the current set and the ''set'' argument.  
  
-__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_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__ 
+; __SIG_SETMASK__: The set of blocked signals is set to the argument ''set''.  
  
+If ''oldset'' is non-null, the previous value of the signal mask is stored in ''oldset''.  
  
-The set of blocked signals is set to the argument  
+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.  
  
-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 VALUE 
-  
-  
- The functions __sigaction__, __sigprocmask__,  
- __sigpending__ and __sigsuspend__ return 0 on success  
- and -1 on error. (In the case of __sigsuspend__ there  
-will be no success, and only the error return with  
- __EINTR__ is possible.) 
+The functions __sigaction__, __sigprocmask__, __sigpending__ and __sigsuspend__ return 0 on success and -1 on error. (In the case of __sigsuspend__ there  
+will be no success, and only the error return with __EINTR__ is possible.) 
 !!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 
+;[ 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.  
  
-__EFAULT__  
+;[EINTR]: System call was interrupted.  
  
-  
-''act'', ''oldact'', ''set'' or ''oldset'' point  
-to memory which is not a valid part of the process address  
-space.  
-  
-  
-__EINTR__  
-  
-  
-System call was interrupted.  
 !!NOTES 
+It is not possible to block [SIGKILL] or [SIGSTOP] with the sigprocmask call. Attempts to do so will be silently ignored.  
  
+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.  
  
-It is not possible to block __SIGKILL__ or __SIGSTOP__  
-with the sigprocmask call . Attempts to do so will be  
-silently ignored
+POSIX (B.3.3.1.3) disallows setting the action for [SIGCHLD] to SIG _IGN . The BSD and SYSV behaviours differ, causing BSD software that sets the action for SIGCHLD to SIG_IGN to fail on Linux
  
+The POSIX spec only defines __SA_NOCLDSTOP__. Use of other ''sa_flags'' is non-portable.  
  
-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
+The __SA_RESETHAND__ flag is compatible with the SVr4 flag of the same name
  
+The __SA_NODEFER__ flag is compatible with the SVr4 flag of the same name under kernels 1.3.9 and newer. On older kernels the Linux implementation allowed the receipt of any signal, not just the one we are installing (effectively overriding any ''sa_mask'' settings).  
  
-POSIX (B. 3.3 .1.3) disallows setting the action for SIGCHLD  
-to SIG_IGN. The BSD and SYSV behaviours differ, causing BSD  
-software that sets the action for SIGCHLD to SIG_IGN to fail  
-on Linux
+The __SA_RESETHAND__ and __SA_NODEFER__ names for SVr4 compatibility are present only in library versions 3. .9 and greater
  
+The __SA_SIGINFO__ flag is specified by POSIX.1b. Support for it was added in Linux 2.2.  
  
-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 sigsetops(3) for details on manipulating signal sets.  
  
-The __SA_RESETHAND__ flag is compatible with the SVr4  
-flag of the same name.  
-  
-  
-The __SA_NODEFER__ flag is compatible with the SVr4 flag  
-of the same name under kernels 1.3.9 and newer. On older  
-kernels the Linux implementation allowed the receipt of any  
-signal, not just the one we are installing (effectively  
-overriding any ''sa_mask'' settings).  
-  
-  
-The __SA_RESETHAND__ and __SA_NODEFER__ names for SVr4  
-compatibility are present only in library versions 3.0.9 and  
-greater.  
-  
-  
-The __SA_SIGINFO__ flag is specified by POSIX.1b. Support  
-for it was added in Linux 2.2.  
-  
-  
-__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 sigsetops(3) for details on manipulating signal  
-sets.  
 !!CONFORMING TO 
+POSIX, SVr4. SVr4 does not document the [EINTR] condition.  
  
-  
-POSIX, SVr4. SVr4 does not document the EINTR  
-condition.  
 !!UNDOCUMENTED 
+Before the introduction of __SA_SIGINFO__ it was also possible to get some additional information, namely by using a sa_handler with second argument of type ''struct  
+sigcontext''. See the relevant kernel sources for details. This use is obsolete now.  
  
-  
-Before the introduction of __SA_SIGINFO__ it was also  
-possible to get some additional information, namely by using  
-a sa_handler with second argument of type ''struct  
-sigcontext''. See the relevant kernel sources for details.  
-This use is obsolete now.  
 !!SEE ALSO 
-  
-  
- kill(1), kill(2), killpg(2),  
- pause(2), raise(3), siginterrupt(3),  
- signal(2), signal(7), sigsetops(3),  
- sigvec(2)  
-----  
+kill(1), kill(2), killpg(2), pause(2), raise(3), siginterrupt(3), signal(2), signal(7), sigsetops(3), sigvec(2), sigemptyset(3)  
This page is a man page (or other imported legacy content). We are unable to automatically determine the license status of this page.