MicrOS
signal.h File Reference
#include <stdint.h>
#include "stdio.h"
#include "micros.h"

Go to the source code of this file.

Macros

#define SIGABRT   0
 (Signal Abort) Abnormal termination, such as is initiated by the abort function. More...
 
#define SIGFPE   1
 (Signal Floating-Point Exception) Erroneous arithmetic operation, such as zero divide or an operation resulting in overflow (not necessarily with a floating-point operation). More...
 
#define SIGILL   2
 (Signal Illegal Instruction) Invalid function image, such as an illegal instruction. This is generally due to a corruption in the code or to an attempt to execute data. More...
 
#define SIGINT   3
 (Signal Interrupt) Interactive attention signal. Generally generated by the application user. More...
 
#define SIGSEGV   4
 (Signal Segmentation Violation) Invalid access to storage: When a program tries to read or write outside the memory it has allocated. More...
 
#define SIGTERM   5
 (Signal Terminate) Termination request sent to program. More...
 
#define SIG_IGN   0
 Ignore Signal: The signal is ignored. More...
 
#define SIG_DFL   1
 Default handling: The signal is handled by the default action for that particular signal. More...
 
#define SIG_ERR   2
 Special return value indicating failure. More...
 

Typedefs

typedef int32_t sig_atomic_t
 Integral type. More...
 
typedef void(* signal_func) (int)
 Signal function signature. More...
 

Functions

int raise (int sig)
 Generates a signal. More...
 
int raise_with_param (int sig, int param)
 Generates a signal with the specified parameter. More...
 
void default_sigabrt_handler (int param)
 Default signal handle for SIGABRT. More...
 
void default_sigfpe_handler (int param)
 Default signal handle for SIGFPE. More...
 
void default_sigill_handler (int param)
 Default signal handle for SIGILL. More...
 
void default_sigint_handler (int param)
 Default signal handle for SIGINT. More...
 
void default_sigsegv_handler (int param)
 Default signal handle for SIGSEGV. More...
 
void default_sigterm_handler (int param)
 Default signal handle for SIGTERM. More...
 
void __signal_init ()
 Initialize default signal handlers. More...
 
signal_func __signal_get_defualt_handler (int sig)
 Get default handler for the specified signal. More...
 

Variables

signal_func signal_handlers [6]
 Array containing all signal handlers. More...
 
void(*)(int) signal (int sig, signal_func func)
 Set function to handle signal. More...
 

Macro Definition Documentation

◆ SIG_DFL

#define SIG_DFL   1

Default handling: The signal is handled by the default action for that particular signal.

◆ SIG_ERR

#define SIG_ERR   2

Special return value indicating failure.

◆ SIG_IGN

#define SIG_IGN   0

Ignore Signal: The signal is ignored.

◆ SIGABRT

#define SIGABRT   0

(Signal Abort) Abnormal termination, such as is initiated by the abort function.

◆ SIGFPE

#define SIGFPE   1

(Signal Floating-Point Exception) Erroneous arithmetic operation, such as zero divide or an operation resulting in overflow (not necessarily with a floating-point operation).

◆ SIGILL

#define SIGILL   2

(Signal Illegal Instruction) Invalid function image, such as an illegal instruction. This is generally due to a corruption in the code or to an attempt to execute data.

◆ SIGINT

#define SIGINT   3

(Signal Interrupt) Interactive attention signal. Generally generated by the application user.

◆ SIGSEGV

#define SIGSEGV   4

(Signal Segmentation Violation) Invalid access to storage: When a program tries to read or write outside the memory it has allocated.

◆ SIGTERM

#define SIGTERM   5

(Signal Terminate) Termination request sent to program.

Typedef Documentation

◆ sig_atomic_t

typedef int32_t sig_atomic_t

Integral type.

Integral type of an object that can be accessed as an atomic entity, even in the presence of asynchronous signals. !

◆ signal_func

typedef void(* signal_func) (int)

Signal function signature.

Function Documentation

◆ __signal_get_defualt_handler()

signal_func __signal_get_defualt_handler ( int  sig)

Get default handler for the specified signal.

Gets default signal handler based on the passed signal type.

◆ __signal_init()

void __signal_init ( )

Initialize default signal handlers.

Assign default signal handlers to the internal array.

◆ default_sigabrt_handler()

void default_sigabrt_handler ( int  param)

Default signal handle for SIGABRT.

This handler can be set by passing SIG_DFL in sig parameter in signal function.

Parameters
paramSignal parameter.

◆ default_sigfpe_handler()

void default_sigfpe_handler ( int  param)

Default signal handle for SIGFPE.

This handler can be set by passing SIG_DFL in sig parameter in signal function.

Parameters
paramSignal parameter.

◆ default_sigill_handler()

void default_sigill_handler ( int  param)

Default signal handle for SIGILL.

This handler can be set by passing SIG_DFL in sig parameter in signal function.

Parameters
paramSignal parameter.

◆ default_sigint_handler()

void default_sigint_handler ( int  param)

Default signal handle for SIGINT.

This handler can be set by passing SIG_DFL in sig parameter in signal function.

Parameters
paramSignal parameter.

◆ default_sigsegv_handler()

void default_sigsegv_handler ( int  param)

Default signal handle for SIGSEGV.

This handler can be set by passing SIG_DFL in sig parameter in signal function.

Parameters
paramSignal parameter.

◆ default_sigterm_handler()

void default_sigterm_handler ( int  param)

Default signal handle for SIGTERM.

This handler can be set by passing SIG_DFL in sig parameter in signal function.

Parameters
paramSignal parameter.

◆ raise()

int raise ( int  sig)

Generates a signal.

The signal value to raise.

Parameters
sigThe signal value to which a handling function is set.
Returns
Returns zero if successful, and a value different from zero otherwise.

◆ raise_with_param()

int raise_with_param ( int  sig,
int  param 
)

Generates a signal with the specified parameter.

The signal value to raise.

Parameters
sigThe signal value to which a handling function is set.
paramThe signal parameter.
Returns
Returns zero if successful, and a value different from zero otherwise.

Variable Documentation

◆ signal

void(*)(int) signal(int sig, signal_func func)

Set function to handle signal.

Specifies a way to handle the signals with the signal number specified by sig.

Parameters
sigThe signal value to which a handling function is set.
funcA pointer to a function. This may either be a function defined by the programmer or one of the following predefined functions: SIG_DFL (handle) or SIG_IGN (ignore).
Returns
If the request is successful, the function returns a pointer to the particular handler function which was in charge of handling this signal before the call, if any. Or either SIG_DFL or SIG_IGN if before the call the signal was being handled by the default handler or was being ignored, respectivelly. If the function was not successful in registering the new signal handling procedure, it returns SIG_ERR and errno may be set to a positive value.

◆ signal_handlers

signal_func signal_handlers[6]

Array containing all signal handlers.