Professional Documents
Culture Documents
PROCESS
A
C B paint
Media Browser
player
Signals
What is a signal?
It is a software notification sent to a process.
It is a short message sent to a process or a group of processes, containing the
number identifying the signal.
Each signal notifies the process that an important event has occurred.
Signals interrupt the process & force it to handle the received signals.
Each signal has an integer number, as well as a mnemonic name.
Signal is identified by:
Identifier
Name
Signal handler
Signals
What is a signal?
Signal handler: is a function that is called when the process receives a
signal.
All signals have a default signal handler.
If no handlers are assigned to a signal, the default handlers are executed.
SIGTERM: default handler is exit ( ) system call.
SIGABRT: default handler is abort ( ) system call.
Signals User Process
15 SIGTERM The process was explicitly killed, cleanup is done to the process
17 SIGCHLD Sent by a child to its parent on exit
Signals
Try signal01.c:
This program is supposed to display a series of numbers.
Ctrl + C kill -2 : this command will cause the program to stop running.
An interrupt / abort signal was sent to the process.
Ctrl + Z kill -20 kill -SIGTSTP : this command will spend the process to the
background, it is an interactive command.
Signals
Try signal01.c:
ps -u: this command provides a snapshot of the
running processes, that are associated with the bash.
fg or % : this command will resume the working
of the process.
kill -SIGCONT kill -18: this command resume
the execution of a process in the background.
kill -SIGSTOP kill -19: this command stops a
process for later resumption.
kill -SIGINT kill -2 : this command stops a
process permanently.
Signals
Sources of generating a signal:
Hardware:
A process attempts to access addresses outside its own address space.
Divide by zero.
Kernel / OS:
Notifying the process that an I/O device for which it has been waiting is available.
Processes:
A child process notifying its parent process that it has terminated.
User:
Pressing keyboard sequences that generate a quit, interrupt or stop signal.
Signals
Signal actions:
• This works for most signals, but there are two signals
Ignore the signal
that can never be ignored: SIGKILL and SIGSTOP.