📄 signal.h.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"><html><head><!-- Copyright 1997 The Open Group, All Rights Reserved --><title><signal.h></title></head><body bgcolor=white><center><font size=2>The Single UNIX ® Specification, Version 2<br>Copyright © 1997 The Open Group</font></center><hr size=2 noshade><h4><a name = "tag_000_008_663"> </a>NAME</h4><blockquote>signal.h - signals</blockquote><h4><a name = "tag_000_008_664"> </a>SYNOPSIS</h4><blockquote><pre><code>#include <signal.h></code></pre></blockquote><h4><a name = "tag_000_008_665"> </a>DESCRIPTION</h4><blockquote>The<i><signal.h></i>header defines the following symbolicconstants, each of which expands to a distinct constantexpression of the type:<pre><code>void (*)(int)</code></pre><p>whose value matches no declarable function.<dl compact><dt>SIG_DFL<dd>Request for default signal handling.<dt>SIG_ERR<dd>Return value from<i><a href="signal.html">signal()</a></i>in case of error.<dt>SIG_HOLD<dd>Request that signal be held.<dt>SIG_IGN<dd>Request that signal be ignored.</dl><p>The following data types are defined through<b>typedef</b>:<dl compact><dt><b>sig_atomic_t</b><dd>Integral type of anobject that can be accessed as an atomic entity, even in thepresence of asynchronous interrupts<dt><b>sigset_t</b><dd>Integral or structure type of an objectused to represent sets of signals.<dt><b>pid_t</b><dd>As described in<i><a href="systypes.h.html"><sys/types.h></a></i>.</dl><p>The<i><signal.h></i>header defines the<b>sigevent</b>structure, which has at least the following members:<pre><code>int sigev_notify notification typeint sigev_signo signal numberunion sigval sigev_value signal valuevoid(*)(union sigval) sigev_notify_function notification function(pthread_attr_t*) sigev_notify_attributes notification attributes</code></pre><p>The following values of<i>sigev_notify</i>are defined:<dl compact><dt>SIGEV_NONE<dd>No asynchronous notification will be deliveredwhen the event of interest occurs.<dt>SIGEV_SIGNAL<dd>A queued signal, with an application-defined value, will be generatedwhen the event of interest occurs.<dt>SIGEV_THREAD<dd>A notification function will be called to perform notification.</dl><p>The <b>sigval</b>union is defined as:<pre><code>int sival_int integer signal valuevoid* sival_ptr pointer signal value</code></pre><p>This header also declares the macros SIGRTMIN and SIGRTMAX,which evaluate to integral expressionsand, if the Realtime Signals Extension option is supported,specify a range of signal numbersthat are reserved for application useand for which the realtime signal behaviour specified in thisspecification is supported.The signal numbers in this range do not overlapany of the signals specified in the following table.<p>The range SIGRTMIN through SIGRTMAXinclusive includes at least RTSIG_MAX signal numbers.<p>It is implementation-dependent whether realtime signal behaviouris supported for other signals.<p>This header also declares the constants that are used to refer to the signalsthat occur in the system. Signals defined here begin with the letters SIG.Each of the signals have distinct positive integral values. The value 0 isreserved for use as the null signal (see<i><a href="kill.html">kill()</a></i>).Additional implementation-dependent signals may occur in the system.<p>The following signals are supported on all implementations (defaultactions are explained below the table):<p><table border=1 align=center><tr valign=top><th align=center><b>Signal</b><th align=center><b>Default Action</b><th align=center><b>Description</b><tr valign=top><td align=left>SIGABRT<td align=left>ii<td align=left><i>Process abort signal.</i><tr valign=top><td align=left>SIGALRM<td align=left>i<td align=left><i>Alarm clock.</i><tr valign=top><td align=left>SIGFPE<td align=left>ii<td align=left><i>Erroneous arithmetic operation.</i><tr valign=top><td align=left>SIGHUP<td align=left>i<td align=left><i>Hangup.</i><tr valign=top><td align=left>SIGILL<td align=left>ii<td align=left><i>Illegal instruction.</i><tr valign=top><td align=left>SIGINT<td align=left>i<td align=left><i>Terminal interrupt signal.</i><tr valign=top><td align=left>SIGKILL<td align=left>i<td align=left><i>Kill (cannot be caught or ignored).</i><tr valign=top><td align=left>SIGPIPE<td align=left>i<td align=left><i>Write on a pipe with no one to read it.</i><tr valign=top><td align=left>SIGQUIT<td align=left>ii<td align=left><i>Terminal quit signal.</i><tr valign=top><td align=left>SIGSEGV<td align=left>ii<td align=left><i>Invalid memory reference.</i><tr valign=top><td align=left>SIGTERM<td align=left>i<td align=left><i>Termination signal.</i><tr valign=top><td align=left>SIGUSR1<td align=left>i<td align=left><i>User-defined signal 1.</i><tr valign=top><td align=left>SIGUSR2<td align=left>i<td align=left><i>User-defined signal 2.</i><tr valign=top><td align=left>SIGCHLD<td align=left>iii<td align=left><i>Child process terminated or stopped.</i><tr valign=top><td align=left>SIGCONT<td align=left>v<td align=left><i>Continue executing, if stopped.</i><tr valign=top><td align=left>SIGSTOP<td align=left>iv<td align=left><i>Stop executing (cannot be caught or ignored).</i><tr valign=top><td align=left>SIGTSTP<td align=left>iv<td align=left><i>Terminal stop signal.</i><tr valign=top><td align=left>SIGTTIN<td align=left>iv<td align=left><i>Background process attempting read.</i><tr valign=top><td align=left>SIGTTOU<td align=left>iv<td align=left><i>Background process attempting write.</i><tr valign=top><td align=left>SIGBUS<td align=left>ii<td align=left><i>Access to an undefined portion of a memory object.</i><tr valign=top><td align=left>SIGPOLL<td align=left>i<td align=left><i>Pollable event.</i><tr valign=top><td align=left>SIGPROF<td align=left>i<td align=left><i>Profiling timer expired.</i><tr valign=top><td align=left>SIGSYS<td align=left>ii<td align=left><i>Bad system call.</i><tr valign=top><td align=left>SIGTRAP<td align=left>ii<td align=left><i>Trace/breakpoint trap.</i><tr valign=top><td align=left>SIGURG<td align=left>iii<td align=left><i>High bandwidth data is available at a socket.</i><tr valign=top><td align=left>SIGVTALRM<td align=left>i<td align=left><i>Virtual timer expired.</i><tr valign=top><td align=left>SIGXCPU<td align=left>ii<td align=left><i>CPU time limit exceeded.</i><tr valign=top><td align=left>SIGXFSZ<td align=left>ii<td align=left><i>File size limit exceeded.</i></table><p>The default actions are as follows:<dl compact><dt>i<dd>Abnormal termination of the process.The process is terminated with all the consequences of<i><a href="_exit.html">_exit()</a></i>except that the status made available to<i><a href="wait.html">wait()</a></i>and<i><a href="waitpid.html">waitpid()</a></i>indicates abnormal termination by the specified signal.<dt>ii<dd>Abnormal termination of the process.Additionally, implementation-dependent abnormal terminationactions, such as creation of a core file, may occur.<dt>iii<dd>Ignore the signal.<dt>iv<dd>Stop the process.<dt>v<dd>Continue the process, if it is stopped; otherwise ignore the signal.</dl><br><p>The header provides a declaration of<b>struct sigaction</b>,including at least the following members:<pre><code>void (*sa_handler)(int) what to do on receipt of signalsigset_t sa_mask set of signals to be blocked during execution of the signal handling functionint sa_flags special flagsvoid (*)(int, siginfo_t *, void *) sa_sigaction pointer to signal handler function or one of the macros SIG_IGN or SIG_DFL</code></pre><p>The storage occupied by <b>sa_handler</b> and <b>sa_sigaction</b> may overlap,and a portable program must not use both simultaneously.<p>The following are declared as constants:<dl compact><dt>SA_NOCLDSTOP<dd>Do not generate SIGCHLD when children stop.<dt>SIG_BLOCK<dd>The resulting set is the union of the current set and the signalset pointed to by the argument<i>set</i>.<dt>SIG_UNBLOCK<dd>The resulting set is the intersection of the current set and the complementof the signal set pointedto by the argument<i>set</i>.<dt>SIG_SETMASK<dd>The resulting set is the signal set pointed to by the argument<i>set</i>.<dt>SA_ONSTACK<dd>Causes signal delivery to occur on an alternate stack.<dt>SA_RESETHAND<dd>Causes signal dispositions to be set to SIG_DFL onentry to signal handlers.<dt>SA_RESTART<dd>Causes certain functions to become restartable.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -