Signals
========
- A signal is an event generated by UNIX/LINUX system in response to some condition.
- On receipt of a signal, process may in turn take some action.
- Signals are generated by some error conditions such as:-
* Memory Segment Violation
* Floating Point Processor error
* Illegal Instruction etc.
- They are generated by shell and terminal handlers.
- They cause interrupts.
- They can also be used to sent from one process to another as a way of passing information or modifying behaviour.
- As default, if a process receives any signal, process will be terminated immediately.
- Usually a core dump file is created.
- The signals are defined by including header file signal.h
- They all begn with “SIG”.
- There are 64 signals in LINUX.
- The can be listed using command :-
kill -l
- Some of the signals are :-
Signal Name Description
SIGABORT Process Abort
SIGALRM Alarm Clock
SIGFPE Floating Point Exception
SIGHUP Hangup
SIGILL Illegal Instruction
SIGINT Terminal Interrupt
SIGKILL Kill (can’t be caught or ignored)
SIGPIPE Write on a pipe with no reader
SIGQUIT Terminal Quit
SIGSEGV Invalid memory segment access (Segmentation Fault)
SIGTERM Termination
SIGUSR1 User-defined signal 1
SIGUSR2 User-defined signal 2
SIGCHLD Child process has stopped or exited
SIGCONT Continue exexuting, if stopped
SIGSTOP Stop Executing (Can’t be caught or ignored)
SIGTSTP Terminal stop signal
SIGTTIN Background process trying to read
SIGTTOU Background process trying to write
- SIGINT can be called using Ctrl-C
- A signal has 3 steps:-
1) raise
2) catch
3) ignore/handle