United States-English |
|
|
HP-UX Reference > Ssignal(5)HP-UX 11i Version 3: February 2007 |
|
NAMEsignal: signal.h — description of signals DESCRIPTIONThe <signal.h> header defines the following symbolic constants, each of which expands to a distinct constant expression of the type: void (*)(int) whose value matches no declarable function.
The following data types are defined through typedef:
This header also declares the constants that are used to refer to the signals that occur in the system. Signals defined here begin with the letters SIG. Each of the signals have distinct positive integral values. The value 0 is reserved for use as the null signal (see kill(2)). Additional implementation-dependent signals may occur in the system. HP-UX supports multiple signal interfaces (see sigaction(2), signal(2), and sigset(3C)) that allow a process to specify the action taken upon receipt of a signal. The following signals are supported on all implementations. The default actions A (Abort), C (Continue), I (Ignore), S (Stop) and T (Abnormal Termination) are explained after the table.
The macros SIGRTMIN and SIGRTMAX evaluate to integral expressions, and specify a range that includes at least {RTSIG_MAX} signal numbers that are reserved for application use and for which the realtime signal extensions are supported (see sigaction(2)). The default actions are as follows:
The header provides a declaration of struct sigaction, including at least the following members:
The storage occupied by sa_handler and sa_sigaction may overlap, and a portable program must not use both simultaneously. The following are declared as constants:
The ucontext_t structure is defined through typedef as described in <ucontext.h>. The mcontext_t structure is defined through typedef as described in <ucontext.h>. The <signal.h> header defines the stack_t type as a structure that includes at least the following members:
The <signal.h> header defines the sigstack structure that includes at least the following members:
The <signal.h> header defines the sigevent structure that includes at least the following members:
The sigev_notify member specifies the notification mechanism to use when an asynchronous event occurs. The following values are defined for the sigev_notify member:
The sigev_signo member specifies the signal to be generated. The sigev_value member is the application-defined value to be passed to the signal-catching function at the time of the signal delivery or to be returned at signal acceptance as the si_value member of the siginfo_t structure. The <signal.h> header defines sigval as a union that includes at least the following members:
The <signal.h> header defines the siginfo_t type as a structure that includes at least the following members:
The si_code member contains a code identifying the cause of the signal. The following values are defined for si_code:
If the signal was not generated by one of the functions or events listed above (such as kill(), raise(), sigqueue(), and other functions), the si_code will be set to an implementation-defined value (see the Code column below) that is not equal to any of the values defined above for si_code. If si_code is one of SI_QUEUE, SI_TIMER, SI_ASYNCIO, or SI_MESGQ, then si_value will contain the application-specified signal value. Otherwise, the contents of si_value are undefined. The macros specified in the Code column of the following table are defined for use as values of si_code that are signal-specific reasons why the signal was generated.
Implementations may support additional si_code values not included in this list, may generate values included in this list under circumstances other than those described in this list, and may contain extensions or limitations that prevent some values from being generated. Implementations will not generate a different value from the ones described in this list for circumstances described in this list. In addition, the following signal-specific information will be available:
For some implementations, the value of si_addr may be inaccurate. The following are declared as functions and may also be defined as macros: void (*bsd_signal(int sig, void (*func)(int)))(int); int kill(pid_t pid, int sig); int killpg(pid_t pgrp, int sig); int raise(int sig); int sigaction(int sig, const struct sigaction *act, struct sigaction *oact); int sigaddset(sigset_t *set, int signo); int sigaltstack(const stack_t *ss, stack_t *oss); int sigdelset(sigset_t *set, int signo); int sigemptyset(sigset_t *set); int sigfillset(sigset_t *set); int sighold(int sig); int sigignore(int sig); int siginterrupt(int sig, int flag); int sigismember(const sigset_t *set, int signo); int sigmask(int signum); void (*signal(int sig, void (*func)(int)))(int); int sigpause(int sig); int sigpending(sigset_t *set); int sigprocmask(int how, const sigset_t *set, sigset_t *oset); int sigqueue(pid_t pid, int sig, const union sigval value); int sigrelse(int sig); void *sigset(int sig, void (*disp)(int)))(int); int sigstack(struct sigstack *ss, struct sigstack *oss); int sigsuspend(const sigset_t *sigmask); int sigtimedwait(const sigset_t *set, siginfo_t * info, const struct timespec *timeout); int sigwait(const sigset_t *set, int *sig); int sigwaitinfo(const sigset_t *set, siginfo_t * info); APPLICATION USAGEUpon receipt of the signal, if signal() is used to set the action to the address of a signal handler, the action for the signal caught is reset to SIG_DFL (except SKGILL, SIGTRAP, and SIGPWR). Then, the signal-catching function is executed. Signal interface routines other than signal() normally do not reset the action for the signal caught. However, sigaction() provides a way of specifying this behavior. The parameters passed to the signal-catching function where signal() is used are:
The parameters passed to the signal-catching function where sigaction() is used and SA_SIGINFO is not specified are:
The parameters passed to the signal-catching function where sigaction() is used and SA_SIGINFO is specified are:
Depending on the value of sig, code can be zero and/or scp can be NULL. The meanings of code and scp and the conditions determining when they are other than zero or NULL are implementation-dependent. It is possible for code to always be zero, and scp to always be NULL. The pointer scp, siginfop, and contextp are valid only during the context of the signal-catching function. Optional parameters can be omitted from the signal-catching function parameter list, in which case the signal-catching function is exactly compatible with UNIX System V. Truly portable software should not use the optional parameters in signal-catching routines. Upon return from the signal-catching function, the receiving process resumes execution at the point where it was interrupted. When a signal is caught during the execution of system calls such as read(), write(), open(), or ioctl() on a slow device (such as a terminal, but not a file on a local filesystem), during a pause() system call or a wait() system call that does not return immediately because a previously stopped or zombie process already exists, the signal-catching function is executed and the interrupted system call returns a -1 to the calling process with errno set to EINTR. When any stop signal (SIGSTOP, SIGTSTP, SIGTTIN, SIGTTOU) is generated for a process, pending SIGCONT signals for that process are discarded. Conversely, when SIGCONT is generated for a process, all pending stop signals for that process are discarded. When SIGCONT is generated for a stopped process, the process is continued, even if the SIGCONT signal is blocked or ignored. If SIGCONT is blocked and not ignored, the signal remains pending until it is either unblocked or a stop signal is generated. Note: When any stop signal (SIGSTOP, SIGTSTP, SIGTIN, SIGTTOU) is posted to threads created with process contention scope, using pthread_kill(), pending SIGCONT signals may not be discarded. Similarly, when SIGCONT is posted to threads created with process contention scope, using pthread_kill(), pending stop signals may not be discarded. However, stop and continue signals posted to threads created with system contention scope, using pthread_kill(), will continue to adhere to the semantics described in the preceding paragraph. SIGKILL is sent by the system if an exec() system call is unsuccessful and the original program has already been deleted. Threads ConsiderationsThe following summarizes the signal model for threads:
Threadsafe ConsiderationsRefer to thread_safety(5) for a list of libc and libpthread interfaces which are not thread-safe, cancellation points, cancel safe, async signal safe, and async cancel safe. WARNINGSThe signals SIGCLD and SIGPWR behave differently than those described above in the list of signals in DESCRIPTION. The actions for these signals is modified as follows:
The hardware program counter is not advanced when a trap occurs. If the signal generated by a hardware trap is received by a signal-catching function in the user program, the instruction that caused the trap is re-executed upon return from the signal-catching function, causing the trap again, unless program flow is altered by the signal-catching function. For example, the longjmp() routine (see setjmp(3C)) can be called. Using longjmp() ensures software portability across different hardware architectures. If the signal generated by a hardware trap is not received by a signal-catching function, that is, if the signal is masked or ignored, there may be one of two results:
SEE ALSOkill(1), init(1M), alarm(2), exit(2), ioctl(2), kill(2), lseek(2), pause(2), select(2), sigaction(2), sigaltstack(2), siginterrupt(2), signal(2), sigpending(2), sigprocmask(2), sigsuspend(2), sigwait(2), umask(2), wait(2), waitid(2), abort(3C), setjmp(3C), sigset(3C), core(4), thread_safety(5), termio(7), glossary(9). |
Printable version | ||
|