yyyy

  • Nextstep4it Jul, 2017
Linux ClassRoom
Feb 2015 | NextStep

“Hi Friends , Welcome to Linux World , this time we will discuss different signals and their usage in linux. Basic Usage of nohup command”
DDifferent Signals in Kill Command and Their Use


A system runs several processes simultaneously. Sometimes it becomes necessary to pass a notification to a process alerting it of an event. A user or the system uses a signal to pass that notification to the process. A signal contains a signal number and is used to control processes. There are a number of signals available for use but most of the time you deal with only a few of them. Each signal is associated with a unique number, a name, and an action. A list of the available signals can be displayed with the kill command using the -l option:



Below Table describes the signals that are most often used.

Number Name Action Response
1 SIGHUP Hang up signal causes a phone line or terminal connection to be dropped. Also used to force arunning daemon to re-read its configuration file. EXIT
2 SIGINT Interrupt signal issued from keyboard, usually by ^c. EXIT
9 SIGKILL Kills a process abruptly by force. EXIT
15 SIGTERM Sends a process a soft TERMination signal to stop it in an orderly fashion. This signal is default. EXIT



The commands used to pass a signal to a process are kill and pkill. These commands are usually used to terminate a process. Ordinary users can kill processes they own, while the root user can kill any process.

The syntax of the kill command to kill a process is:

# kill PID  # kill -s <signal name  or number> PID

Specify multiple PIDs if you wish to kill all of them in one go.

The syntax of the pkill command to kill a process is:

# pkill process_name  # pkill -s <signal name  or number> process_name

Specify multiple process names if you wish to kill all of them in one go.

Let us look at a few examples for a better understanding.

To pass the soft terminate signal to the Cron daemon crond, use one of the following to determine its PID:

nextstep4it@localhost:~$ ps -ef | grep crond  nextste+ 10309  9997  0 11:52 pts/1    00:00:00 grep --color=auto crond

 

  • Nextstep4it Jul, 2017
Shares 0