Monday, 19 May 2014

C Library -

Post By: Hanan Mannan
Contact Number: Pak (+92)-321-59-95-634
-------------------------------------------------------

C Library - <signal.h>

Introduction

The signal.h header defines a variable type sig_atomic_t, two function calls and several macros to handle different signals reported during a program's execution.

Library Variables

Following is the variable type defined in the header signal.h:
S.N.Variable & Description
1sig_atomic_t 
This is of int type and is used as a variable in a signal handler. This is an integral type of an object that can be accessed as an atomic entity, even in the presence of asynchronous signals.

Library Macros

Following are the macros defined in the header signal.h and these macros will be used in two functions listed below. The SIG_ macros are used with the signal function to define signal functions.
S.N.Macro & Description
1SIG_DFL
Default singal handler
2SIG_ERR
Represents a signal error.
3SIG_IGN
Signal ignore.
The SIG macros are used to represent a signal number in the following conditions:
S.N.Macro & Description
1SIGABRT
Abnormal program termination
2SIGFPE
Floating-point error like division by zero.
3SIGILL
Illegal operation.
4SIGINT
Interrupt signal such as ctrl-C.
5SIGSEGV
Invalid access to storage like segment violation.
6SIGTERM
Termination request.

Library Functions

Following are the functions defined in the header signal.h:
S.N.Function & Description
1void (*signal(int sig, void (*func)(int)))(int)
This function sets a function to handle signal ie. a signal handler.
2int raise(int sig)
This function causes signal sig to be generated. The sig argument is compatible with the SIG macros.

0 comments: