The value returned byTEMP_FAILURE_RETRY is whatever valueexpressionproduced.
EINTRentirely and provides a more convenient approach: to restart the interrupted primitive,instead of making it fail. If you choose this approach,you need not be concerned withEINTR .
sigactionto establish a signal handler,you can specify how that handler should behave. If you specify theSA_RESTART flag,return from that handler will resume a primitive; otherwise,return from that handler will causeEINTR . See sectionsigaction .
siginterruptfunction. See section.
sigactionorsiginterrupt what a particular handler should do,it uses a default choice. The default choice in the GNU library depends on the feature test macros you have defined. If you define_BSD_SOURCE or_GNU_SOURCE before callingsignal ,the default is to resume primitives; otherwise,the default is to make them fail withEINTR . (The library contains alternate versions of thesignal function,and the feature test macros determine which one you really call.) See section.
EINTRamong the error codes it can return.
readorwrite is interrupted by a signal after transferring part of the data. In this case,the function returns the number of bytes already transferred,indicating partial success.
readorwrite into two would read or write two records. Actually,there is no problem,because interruption after a partial transfer cannot happen on such devices; they always transfer an entire record in one burst,with no waiting once data transfer has started.
raisefunction. This function is declared in`signal.h'.
intraise(intsignum)
-
The
raise function sends the signalsignumto the calling process. It returns zero if successful and a nonzero value if it fails. About the only reason for failure would be if the value ofsignumis invalid.
intgsignal(intsignum)
-
The
gsignal function does the same thing asraise ; it is provided only for compatibility with SVID.
raiseis to reproduce the default behavior of a signal that you have trapped. For instance,suppose a user of your program types the SUSP character (usuallyC-z; see section) to send it an interactive stop stop signal (SIGTSTP ),and you want to clean up some internal data buffers before stopping. You might set this up like this:
#include
/ When a stop signal arrives,set the action back to the default
and then resend the signal after doing cleanup actions. /
void
tstp_handler (int sig)
{
signal (SIGTSTP,SIG_DFL);
/ Do cleanup actions here. /
...
raise (SIGTSTP);
}
/ When the process is continued again,restore the signal handler. /
void
cont_handler (int sig)
{
signal (SIGCONT,cont_handler);
signal (SIGTSTP,tstp_handler);
}
/ Enable both handlers during program initialization. / (编辑:威海站长网)
【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!
|