MentOS  0.8.0
The Mentoring Operating System
Classes | Macros | Typedefs | Enumerations | Functions
signal.h File Reference

Signals definition. More...

Go to the source code of this file.

Classes

struct  sigset
 Structure used to mask and unmask signals. More...
 
struct  sigaction
 Holds the information on how to handle a specific signal. More...
 
union  sigval
 Data passed with signal info. More...
 
struct  siginfo
 Stores information about an occurrence of a specific signal. More...
 

Macros

#define SA_NOCLDSTOP   0x00000001U
 Turn off SIGCHLD when children stop.
 
#define SA_NOCLDWAIT   0x00000002U
 Flag on SIGCHLD to inhibit zombies.
 
#define SA_SIGINFO   0x00000004U
 sa_sigaction specifies the signal-handling function for signum.
 
#define SA_ONSTACK   0x08000000U
 Indicates that a registered stack_t will be used.
 
#define SA_RESTART   0x10000000U
 Flag to get restarting signals (which were the default long ago)
 
#define SA_NODEFER   0x40000000U
 Prevents the current signal from being masked in the handler.
 
#define SA_RESETHAND   0x80000000U
 Clears the handler when the signal is delivered.
 
#define SIG_DFL   ((sighandler_t)0)
 Default signal handling.
 
#define SIG_IGN   ((sighandler_t)1)
 Ignore signal.
 
#define SIG_ERR   ((sighandler_t)-1)
 Error return from signal.
 

Typedefs

typedef void(* sighandler_t) (int)
 Type of a signal handler.
 
typedef struct sigset sigset_t
 Structure used to mask and unmask signals. More...
 
typedef struct sigaction sigaction_t
 Holds the information on how to handle a specific signal.
 
typedef union sigval sigval_t
 Data passed with signal info.
 
typedef struct siginfo siginfo_t
 Stores information about an occurrence of a specific signal.
 

Enumerations

enum  signal_type_t {
  SIGHUP = 1 , SIGINT = 2 , SIGQUIT = 3 , SIGILL = 4 ,
  SIGTRAP = 5 , SIGABRT = 6 , SIGEMT = 7 , SIGFPE = 8 ,
  SIGKILL = 9 , SIGBUS = 10 , SIGSEGV = 11 , SIGSYS = 12 ,
  SIGPIPE = 13 , SIGALRM = 14 , SIGTERM = 15 , SIGUSR1 = 16 ,
  SIGUSR2 = 17 , SIGCHLD = 18 , SIGPWR = 19 , SIGWINCH = 20 ,
  SIGURG = 21 , SIGPOLL = 22 , SIGSTOP = 23 , SIGTSTP = 24 ,
  SIGCONT = 25 , SIGTTIN = 26 , SIGTTOU = 27 , SIGVTALRM = 28 ,
  SIGPROF = 29 , SIGXCPU = 30 , SIGXFSZ = 31 , NSIG ,
  SIGHUP = 1 , SIGINT = 2 , SIGQUIT = 3 , SIGILL = 4 ,
  SIGTRAP = 5 , SIGABRT = 6 , SIGEMT = 7 , SIGFPE = 8 ,
  SIGKILL = 9 , SIGBUS = 10 , SIGSEGV = 11 , SIGSYS = 12 ,
  SIGPIPE = 13 , SIGALRM = 14 , SIGTERM = 15 , SIGUSR1 = 16 ,
  SIGUSR2 = 17 , SIGCHLD = 18 , SIGPWR = 19 , SIGWINCH = 20 ,
  SIGURG = 21 , SIGPOLL = 22 , SIGSTOP = 23 , SIGTSTP = 24 ,
  SIGCONT = 25 , SIGTTIN = 26 , SIGTTOU = 27 , SIGVTALRM = 28 ,
  SIGPROF = 29 , SIGXCPU = 30 , SIGXFSZ = 31 , NSIG
}
 List of signals. More...
 
enum  signal_sender_code_t {
  SI_NOINFO , SI_USER , SI_KERNEL , SI_QUEUE ,
  SI_TIMER , SI_ASYNCIO , SI_MESGQ , ILL_ILLOPC ,
  ILL_ILLOPN , ILL_ILLADR , ILL_ILLTRP , ILL_PRVOPC ,
  ILL_PRVREG , ILL_COPROC , ILL_BADSTK , FPE_INTDIV ,
  FPE_INTOVF , FPE_FLTDIV , FPE_FLTOVF , FPE_FLTUND ,
  FPE_FLTRES , FPE_FLTINV , FPE_FLTSUB , SEGV_MAPERR ,
  SEGV_ACCERR , BUS_ADRALN , BUS_ADRERR , BUS_OBJERR ,
  TRAP_BRKPT , TRAP_TRACE , CLD_EXITED , CLD_KILLED ,
  CLD_DUMPED , CLD_TRAPPED , CLD_STOPPED , CLD_CONTINUED ,
  POLL_IN , POLL_OUT , POLL_MSG , POLL_ERR ,
  POLL_PRI , POLL_HUP , SI_NOINFO , SI_USER ,
  SI_KERNEL , SI_QUEUE , SI_TIMER , SI_ASYNCIO ,
  SI_MESGQ , ILL_ILLOPC , ILL_ILLOPN , ILL_ILLADR ,
  ILL_ILLTRP , ILL_PRVOPC , ILL_PRVREG , ILL_COPROC ,
  ILL_BADSTK , FPE_INTDIV , FPE_INTOVF , FPE_FLTDIV ,
  FPE_FLTOVF , FPE_FLTUND , FPE_FLTRES , FPE_FLTINV ,
  FPE_FLTSUB , SEGV_MAPERR , SEGV_ACCERR , BUS_ADRALN ,
  BUS_ADRERR , BUS_OBJERR , TRAP_BRKPT , TRAP_TRACE ,
  CLD_EXITED , CLD_KILLED , CLD_DUMPED , CLD_TRAPPED ,
  CLD_STOPPED , CLD_CONTINUED , POLL_IN , POLL_OUT ,
  POLL_MSG , POLL_ERR , POLL_PRI , POLL_HUP
}
 Codes that indentify the sender of a signal. More...
 
enum  sigmask_how_t {
  SIG_BLOCK , SIG_UNBLOCK , SIG_SETMASK , SIG_BLOCK ,
  SIG_UNBLOCK , SIG_SETMASK
}
 Defines what to do with the provided signal mask. More...
 

Functions

int kill (pid_t pid, int sig)
 Send signal to a process. More...
 
sighandler_t signal (int signum, sighandler_t handler)
 Sets the disposition of the signal signum to handler. More...
 
int sigaction (int signum, const sigaction_t *act, sigaction_t *oldact)
 Examine and change a signal action. More...
 
int sigprocmask (int how, const sigset_t *set, sigset_t *oldset)
 Examine and change blocked signals. More...
 
const char * strsignal (int sig)
 Returns the string describing the given signal. More...
 
int sigemptyset (sigset_t *set)
 Prepare an empty set. More...
 
int sigfillset (sigset_t *set)
 Prepare a full set. More...
 
int sigaddset (sigset_t *set, int signum)
 Adds the given signal to the correct set. More...
 
int sigdelset (sigset_t *set, int signum)
 Removes the given signal to the correct set. More...
 
int sigismember (sigset_t *set, int signum)
 Checks if the given signal is part of the set. More...
 

Detailed Description

Signals definition.

Typedef Documentation

◆ sigset_t

typedef struct sigset sigset_t

Structure used to mask and unmask signals.

Each unsigned long consists of 32 bits, thus, the maximum number of signals that may be declared is 64. Signals are divided into two cathegories, identified by the two unsigned longs: [ 1, 31] corresponds to normal signals; [32, 64] corresponds to real-time signals.

Enumeration Type Documentation

◆ sigmask_how_t

Defines what to do with the provided signal mask.

Enumerator
SIG_BLOCK 

The set of blocked signals is the union of the current set and the set argument.

SIG_UNBLOCK 

The signals in set are removed from the current set of blocked signals. It is permissible to attempt to unblock a signal which is not blocked.

SIG_SETMASK 

The set of blocked signals is set to the argument set.

SIG_BLOCK 

The set of blocked signals is the union of the current set and the set argument.

SIG_UNBLOCK 

The signals in set are removed from the current set of blocked signals. It is permissible to attempt to unblock a signal which is not blocked.

SIG_SETMASK 

The set of blocked signals is set to the argument set.

◆ signal_sender_code_t

Codes that indentify the sender of a signal.

Enumerator
SI_NOINFO 

Unable to determine complete signal information.

SI_USER 

Signal sent by kill(), pthread_kill(), raise(), abort() or alarm().

SI_KERNEL 

Generic kernel function.

SI_QUEUE 

Signal was sent by sigqueue().

SI_TIMER 

Signal was generated by expiration of a timer set by timer_settimer().

SI_ASYNCIO 

Signal was generated by completion of an asynchronous I/O request.

SI_MESGQ 

Signal was generated by arrival of a message on an empty message queue.

ILL_ILLOPC 

Illegal opcode.

ILL_ILLOPN 

Illegal operand.

ILL_ILLADR 

Illegal addressing mode.

ILL_ILLTRP 

Illegal trap.

ILL_PRVOPC 

Privileged opcode.

ILL_PRVREG 

Privileged register.

ILL_COPROC 

Coprocessor error.

ILL_BADSTK 

Internal stack error.

FPE_INTDIV 

Integer divide-by-zero.

FPE_INTOVF 

Integer overflow.

FPE_FLTDIV 

Floating point divide-by-zero.

FPE_FLTOVF 

Floating point overflow.

FPE_FLTUND 

Floating point underflow.

FPE_FLTRES 

Floating point inexact result.

FPE_FLTINV 

Invalid floating point operation.

FPE_FLTSUB 

Subscript out of range.

SEGV_MAPERR 

Address not mapped.

SEGV_ACCERR 

Invalid permissions.

BUS_ADRALN 

Invalid address alignment.

BUS_ADRERR 

Non-existent physical address.

BUS_OBJERR 

Object-specific hardware error.

TRAP_BRKPT 

Process breakpoint.

TRAP_TRACE 

Process trace trap.

CLD_EXITED 

Child has exited.

CLD_KILLED 

Child has terminated abnormally and did not create a core file.

CLD_DUMPED 

Child has terminated abnormally and created a core file.

CLD_TRAPPED 

Traced child has trapped.

CLD_STOPPED 

Child has stopped.

CLD_CONTINUED 

Stopped child has continued.

POLL_IN 

Data input available.

POLL_OUT 

Output buffers available.

POLL_MSG 

Input message available.

POLL_ERR 

I/O error.

POLL_PRI 

High priority input available.

POLL_HUP 

Device disconnected.

SI_NOINFO 

Unable to determine complete signal information.

SI_USER 

Signal sent by kill(), pthread_kill(), raise(), abort() or alarm().

SI_KERNEL 

Generic kernel function.

SI_QUEUE 

Signal was sent by sigqueue().

SI_TIMER 

Signal was generated by expiration of a timer set by timer_settimer().

SI_ASYNCIO 

Signal was generated by completion of an asynchronous I/O request.

SI_MESGQ 

Signal was generated by arrival of a message on an empty message queue.

ILL_ILLOPC 

Illegal opcode.

ILL_ILLOPN 

Illegal operand.

ILL_ILLADR 

Illegal addressing mode.

ILL_ILLTRP 

Illegal trap.

ILL_PRVOPC 

Privileged opcode.

ILL_PRVREG 

Privileged register.

ILL_COPROC 

Coprocessor error.

ILL_BADSTK 

Internal stack error.

FPE_INTDIV 

Integer divide-by-zero.

FPE_INTOVF 

Integer overflow.

FPE_FLTDIV 

Floating point divide-by-zero.

FPE_FLTOVF 

Floating point overflow.

FPE_FLTUND 

Floating point underflow.

FPE_FLTRES 

Floating point inexact result.

FPE_FLTINV 

Invalid floating point operation.

FPE_FLTSUB 

Subscript out of range.

SEGV_MAPERR 

Address not mapped.

SEGV_ACCERR 

Invalid permissions.

BUS_ADRALN 

Invalid address alignment.

BUS_ADRERR 

Non-existent physical address.

BUS_OBJERR 

Object-specific hardware error.

TRAP_BRKPT 

Process breakpoint.

TRAP_TRACE 

Process trace trap.

CLD_EXITED 

Child has exited.

CLD_KILLED 

Child has terminated abnormally and did not create a core file.

CLD_DUMPED 

Child has terminated abnormally and created a core file.

CLD_TRAPPED 

Traced child has trapped.

CLD_STOPPED 

Child has stopped.

CLD_CONTINUED 

Stopped child has continued.

POLL_IN 

Data input available.

POLL_OUT 

Output buffers available.

POLL_MSG 

Input message available.

POLL_ERR 

I/O error.

POLL_PRI 

High priority input available.

POLL_HUP 

Device disconnected.

◆ signal_type_t

List of signals.

Enumerator
SIGHUP 

Hang up detected on controlling terminal or death of controlling process.

SIGINT 

Issued if the user sends an interrupt signal (Ctrl + C).

SIGQUIT 

Issued if the user sends a quit signal (Ctrl + D).

SIGILL 

Illegal Instruction.

SIGTRAP 

Trace/breakpoint trap.

SIGABRT 

Abort signal from abort().

SIGEMT 

Emulator trap.

SIGFPE 

Floating-point arithmetic exception.

SIGKILL 

If a process gets this signal it must quit immediately and will not perform any clean-up operations.

SIGBUS 

Bus error (bad memory access).

SIGSEGV 

Invalid memory reference.

SIGSYS 

Bad system call (SVr4).

SIGPIPE 

Broken pipe: write to pipe with no readers.

SIGALRM 

Alarm clock signal (used for timers).

SIGTERM 

Software termination signal (sent by kill by default).

SIGUSR1 

User-defined signal 1.

SIGUSR2 

User-defined signal 2.

SIGCHLD 

Child stopped or terminated.

SIGPWR 

Power failure.

SIGWINCH 

Window resize signal.

SIGURG 

Urgent condition on socket.

SIGPOLL 

Pollable event.

SIGSTOP 

Stop process.

SIGTSTP 

Stop typed at terminal.

SIGCONT 

Continue if stopped.

SIGTTIN 

Terminal input for background process.

SIGTTOU 

Terminal output for background process.

SIGVTALRM 

Virtual alarm clock.

SIGPROF 

Profiling timer expired.

SIGXCPU 

CPU time limit exceeded.

SIGXFSZ 

File size limit exceeded.

SIGHUP 

Hang up detected on controlling terminal or death of controlling process.

SIGINT 

Issued if the user sends an interrupt signal (Ctrl + C).

SIGQUIT 

Issued if the user sends a quit signal (Ctrl + D).

SIGILL 

Illegal Instruction.

SIGTRAP 

Trace/breakpoint trap.

SIGABRT 

Abort signal from abort().

SIGEMT 

Emulator trap.

SIGFPE 

Floating-point arithmetic exception.

SIGKILL 

If a process gets this signal it must quit immediately and will not perform any clean-up operations.

SIGBUS 

Bus error (bad memory access).

SIGSEGV 

Invalid memory reference.

SIGSYS 

Bad system call (SVr4).

SIGPIPE 

Broken pipe: write to pipe with no readers.

SIGALRM 

Alarm clock signal (used for timers).

SIGTERM 

Software termination signal (sent by kill by default).

SIGUSR1 

User-defined signal 1.

SIGUSR2 

User-defined signal 2.

SIGCHLD 

Child stopped or terminated.

SIGPWR 

Power failure.

SIGWINCH 

Window resize signal.

SIGURG 

Urgent condition on socket.

SIGPOLL 

Pollable event.

SIGSTOP 

Stop process.

SIGTSTP 

Stop typed at terminal.

SIGCONT 

Continue if stopped.

SIGTTIN 

Terminal input for background process.

SIGTTOU 

Terminal output for background process.

SIGVTALRM 

Virtual alarm clock.

SIGPROF 

Profiling timer expired.

SIGXCPU 

CPU time limit exceeded.

SIGXFSZ 

File size limit exceeded.

Function Documentation

◆ kill()

int kill ( pid_t  pid,
int  sig 
)

Send signal to a process.

Parameters
pidThe pid of the process to which we send the signal.
sigThe type of signal to send.
Returns
On success 0, on error -1 and errno is set appropriately.

◆ sigaction()

int sigaction ( int  signum,
const sigaction_t act,
sigaction_t oldact 
)

Examine and change a signal action.

Parameters
signumSpecifies the signal and can be any valid signal except SIGKILL and SIGSTOP.
actIf non-NULL, the new action for signal signum is installed from act.
oldactIf non-NULL, the previous action is saved in oldact.
Returns
returns 0 on success; on error, -1 is returned, and errno is set to indicate the error.

◆ sigaddset()

int sigaddset ( sigset_t set,
int  signum 
)

Adds the given signal to the correct set.

Parameters
setThe set to manipulate.
signumThe signalt to handle.
Returns
0 on success and -1 on error.

◆ sigdelset()

int sigdelset ( sigset_t set,
int  signum 
)

Removes the given signal to the correct set.

Parameters
setThe set to manipulate.
signumThe signalt to handle.
Returns
0 on success and -1 on error.

◆ sigemptyset()

int sigemptyset ( sigset_t set)

Prepare an empty set.

Parameters
setThe set to manipulate.
Returns
0 on success and -1 on error.

◆ sigfillset()

int sigfillset ( sigset_t set)

Prepare a full set.

Parameters
setThe set to manipulate.
Returns
0 on success and -1 on error.

◆ sigismember()

int sigismember ( sigset_t set,
int  signum 
)

Checks if the given signal is part of the set.

Parameters
setThe set to manipulate.
signumThe signalt to handle.
Returns
1 if signum is a member of set, 0 if signum is not a member, and -1 on error.

◆ signal()

sighandler_t signal ( int  signum,
sighandler_t  handler 
)

Sets the disposition of the signal signum to handler.

Parameters
signumThe signal number.
handlerThe handler for the signal.
Returns
The previous value of the signal handler, or SIG_ERR on error.

◆ sigprocmask()

int sigprocmask ( int  how,
const sigset_t set,
sigset_t oldset 
)

Examine and change blocked signals.

Parameters
howDetermines the behavior of the call.
setThe set of signals to manage by the function.
oldsetIf non-NULL, the previous value of the signal mask is stored here.
Returns
returns 0 on success, and -1 on error (errno is set to indicate the cause).

If set is NULL, then the signal mask is unchanged (i.e., how is ignored), but the current value of the signal mask is nevertheless returned in oldset (if it is not NULL).

◆ strsignal()

const char* strsignal ( int  sig)

Returns the string describing the given signal.

Parameters
sigThe signal to inquire.
Returns
String representing the signal.