Signal in Operating System

Process States

About

In an OS, the program are entities and they communicate with the Signals principle.

They are considered an (Linux) inter-process communication mechanism.

They are used to signal asynchronous events to one or more processes.

A signal could be generated:

  • by a keyboard interrupt
  • by an error condition.
  • as job control commands to child processes
Type Mean of Communication between
Interrupts the CPU and the OS kernel
Signals the OS kernel and OS processes

Signals may be initiated by:

  • the OS kernel (e.g: SIGFPE, SIGSEGV, SIGIO),
  • or by a process(kill()).

They are eventually managed by the OS kernel, which delivers them to the target thread/process, invoking either:

  • a generic action (ignore, terminate, terminate and dump core)
  • or a process-provided signal handler.

Hardware interrupts can generate signals, like a keyboard interrupt generates SIGINT. Thus interrupts and signals are closely tied to each other.

Number Name Description
11 SIGSEGV segmentation fault
SIGINT
SIGTERM (generated with the kill command
SIGINFO ask for info (generated, for example, by typing the status character, typically control-T, although on some platforms, such as Mac OS X, the status character is not set by default, so you must set it with stty(1) in order to use it)
SIGUSR1 a little bit the same meaning than SIGINFO

Management

List

kill -l

Example

# Handle shutdowns
function gracefulshutdown {
  shutdown.sh
}

trap gracefulshutdown SIGINT
trap gracefulshutdown SIGTERM
trap gracefulshutdown SIGKILL

Trap

See trap

Example: calling the exit function, the following finish function will run.

#!/bin/bash
function finish {
  # Your cleanup code here
}
trap finish EXIT

Documentation / Reference





Discover More
Bash Liste Des Attaques Ovh
Bash - (Return|Exit) (Value|Status)

The return status (also known as Exit Status of Exit Code) of a simple command is its exit status as provided by: the posix 1003.1 waitpid function, or 128+n if the command was terminated by signal...
Bash Liste Des Attaques Ovh
Bash - Kill a process

How to kill a process kill is bash builtin command Send the signal named by sigspec or signum to the processes named by pid or jobspec. sigspec is either a case-insensitive signal name such as...
Instruction Cycle
Instruction Cycle - Interrupt

In a instruction cycle, the interrupt is the last part. Interrupts occur at random times during the execution of a program, in response to signals from hardware. Type Mean of Communication between ...
Java Conceptuel Diagram
Java Concurrency - Thread Dump

A thread dump consists of: an thread header (followed by the thread stack) the thread stack, including thread state, for all Java threads in the virtual machine. The thread dump does not terminate...
OS - strace (Interactions between processes and the Linux kernel)

strace monitor and tamper interactions between processes and the Linux kernel, which include system calls, signal deliveries, and changes of process state. The operation of strace is made possible by the...
Process States
Process - Inter Process Communication (IPC)

An Inter Process Communication (IPC) describes the fact that two or more processes exchange information. IPC is used not just for communication between processes on the same system, but also on different...
Process States
The SIGINT signal (signal interrupt)

The SIGINT is a signal that asks the process to interrupt its work.



Share this page:
Follow us:
Task Runner