C Standard Library Reference Guide (9) signal.h

Source: Internet
Author: User

9. signal.h

A method that signal the signal generated by the handler when it is run.

Macro:

Sig_dfl

Sig_err

Sig_ign

Sigabrt

Sigfpe

Sigill

SIGINT

SIGSEGV

Sigterm

Function:

Signal ();

Raise ();

Variable:

typedef sig_atomic_t

9.1. Variables and definitions

The type sig_atomic_t is an int, as a variable in the handler of the signal function. Sig_ macros are used in signal functions to define signal functions.

SIG_DFL default handler.

Sig_err indicates an error signal.

Sig_ign ignore the signal.

The SIG macro represents a signal number in the following cases.

SIGABRT terminated abnormally (generated by the Abort function).

SIGFPE floating-point error (generated by 0 in addition to running, unreasonable operation).

Sigill Illegal operation (instruction).

SIGINT Interactive signals (such as our familiar ctrl-c).

SIGSEGV Illegal store access (segment error, memory error).

Sigterm terminate the request.

9.2. Signal

Statement:

void (*signal (int sig, Void (*FUNC) (int))) (int);

This function manages how a signal should be manipulated. The sig represents a signal number that is compatible with the SIG macro. The Func function is invoked when the signal is generated. If the function is SIG_DFL, the default handler is invoked. If the Func is sig_ign, the signal is ignored. If Func points to a function, the function is invoked when a signal is detected and the default handler is executed. The function must carry an int parameter to represent the signal number. The function may be return,abort,exit, or longjmp terminated. When the function terminates, the program continues to execute from the interrupt (unless it is the result undefined signal sigfpe).

If the signal call succeeds, a pointer to the handler of the previously specified signal type is returned. If the signal call fails, the SIG_ERR is returned and the errno is set to a reasonable value.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.