MentOS
0.8.0
The Mentoring Operating System
|
Signals definition. More...
Go to the source code of this file.
Classes | |
struct | sigset_t |
Structure used to mask and unmask signals. More... | |
struct | sigaction_t |
Holds the information on how to handle a specific signal. More... | |
struct | sighand_t |
Describes how each signal must be handled. More... | |
union | sigval |
Data passed with signal info. More... | |
struct | siginfo_t |
Stores information about an occurrence of a specific signal. More... | |
struct | sigqueue_t |
An entry of the signal queue. More... | |
struct | sigpending_t |
Keeps information of pending signals. 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. | |
#define | SEND_SIG_NOINFO ((siginfo_t *)0) |
These can be the second arg to send_sig_info/send_group_sig_info. | |
Typedefs | |
typedef void(* | sighandler_t) (int) |
Type of a signal handler. | |
typedef struct sigset_t | sigset_t |
Structure used to mask and unmask signals. More... | |
typedef struct sigaction_t | sigaction_t |
Holds the information on how to handle a specific signal. | |
typedef struct sighand_t | sighand_t |
Describes how each signal must be handled. | |
typedef union sigval | sigval_t |
Data passed with signal info. | |
typedef struct siginfo_t | siginfo_t |
Stores information about an occurrence of a specific signal. | |
typedef struct sigqueue_t | sigqueue_t |
An entry of the signal queue. | |
typedef struct sigpending_t | sigpending_t |
Keeps information of pending signals. | |
Functions | |
long | sys_sigreturn (struct pt_regs *f) |
Handle the return from a signal handler. More... | |
int | do_signal (struct pt_regs *f) |
Handles the signals of the current process. More... | |
int | signals_init (void) |
Initialize the signals. More... | |
int | sys_kill (pid_t pid, int sig) |
Send signal to one specific process. More... | |
sighandler_t | sys_signal (int signum, sighandler_t handler, uint32_t sigreturn_addr) |
Sets the disposition of the signal signum to handler. More... | |
int | sys_sigaction (int signum, const sigaction_t *act, sigaction_t *oldact, uint32_t sigreturn_addr) |
Examine and change a signal action. More... | |
int | sys_sigprocmask (int how, const sigset_t *set, sigset_t *oldset) |
Examine and change blocked signals. More... | |
int | sys_sigpending (sigset_t *set) |
Provides a snapshot of pending 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... | |
Signals definition.
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.
enum sigmask_how_t |
Defines what to do with the provided signal mask.
enum 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. |
enum signal_type_t |
Signal codes.
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. |
int do_signal | ( | struct pt_regs * | f | ) |
Handles the signals of the current process.
f | The address of the stack area where the User Mode register contents of the current process are saved. |
regs
have been modified to handle it (e.g., eip is now poiting at the handler). int sigaddset | ( | sigset_t * | set, |
int | signum | ||
) |
Adds the given signal to the correct set.
set | The set to manipulate. |
signum | The signalt to handle. |
int sigdelset | ( | sigset_t * | set, |
int | signum | ||
) |
Removes the given signal to the correct set.
set | The set to manipulate. |
signum | The signalt to handle. |
int sigemptyset | ( | sigset_t * | set | ) |
Prepare an empty set.
set | The set to manipulate. |
int sigfillset | ( | sigset_t * | set | ) |
Prepare a full set.
set | The set to manipulate. |
int sigismember | ( | sigset_t * | set, |
int | signum | ||
) |
Checks if the given signal is part of the set.
set | The set to manipulate. |
signum | The signalt to handle. |
int signals_init | ( | void | ) |
Initialize the signals.
const char* strsignal | ( | int | sig | ) |
Returns the string describing the given signal.
sig | The signal to inquire. |
int sys_kill | ( | pid_t | pid, |
int | sig | ||
) |
Send signal to one specific process.
pid | The PID of the process. |
sig | The signal to be sent. |
int sys_sigaction | ( | int | signum, |
const sigaction_t * | act, | ||
sigaction_t * | oldact, | ||
uint32_t | sigreturn_addr | ||
) |
Examine and change a signal action.
signum | Specifies the signal and can be any valid signal except SIGKILL and SIGSTOP. |
act | If non-NULL, the new action for signal signum is installed from act. |
oldact | If non-NULL, the previous action is saved in oldact. |
sigreturn_addr | The address of the sigreturn function. |
sighandler_t sys_signal | ( | int | signum, |
sighandler_t | handler, | ||
uint32_t | sigreturn_addr | ||
) |
Sets the disposition of the signal signum to handler.
signum | The signal number. |
handler | The handler for the signal. |
sigreturn_addr | The address of the sigreturn function. |
int sys_sigpending | ( | sigset_t * | set | ) |
Provides a snapshot of pending signals.
set | where the set of pending signals is returned. |
Examine and change blocked signals.
how | Determines the behavior of the call. |
set | The set of signals to manage by the function. |
oldset | If non-NULL, the previous value of the signal mask is stored here. |
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).
long sys_sigreturn | ( | struct pt_regs * | f | ) |
Handle the return from a signal handler.
f | The stack frame when returning from a signal handler. |