Module 70 kill

Previous Table of Contents Next


Module 70
kill

DESCRIPTION

The external and internal kill command is used to send signals to processes currently executing on the system. Its name is derived from the fact that most signals will cause a process to die, thus it kills the process. Normally kill is used in conjunction with the ps command, system s, or the PID or ? variable.

COMMAND FORMAT

Following is the general format of the kill command.

 kill [ -signal ] PID ...      kill -signal -PGID ...      kill -l 

BSD (Berkeley)
kill [ -signal ] PID ...
kill -l

C shell & Korn shell
The C shell and Korn shell have additional formats for the internal kill command if job control is supported on the system.
kill -l
kill [ -signal ] [ PID... ]
kill [ -signal ] [ %n... ]

Options

The following options may be used to control how kill functions.

- signal Specifies the signal sent to the given PIDs. You can use numbers or the corresponding names . Refer to the following table.

C shell & Korn shell
-l Displays (lists) the signal numbers and names.
%n Specifies a job number to kill.

If no signal is specified, signal 15 is used. Signal 15 is the signal for software termination, which causes the program to perform internal cleanup, if it is written to do so, and then exit.

Arguments

The following arguments may be passed to the kill command.

PID ... One or more Process IDs you wish to send a signal.
PGID ... One or more Group Process IDs you wish to send a signal. All processes with the PGID group process ID are sent the signal.
If the specified PID is zero, then the signal is sent to your login shell and all processes started by it. For example,
 kill 0 
sends a software terminate signal to all of your processes, even your shell. The shell catches and ignores the signal. But most other commands are terminated .

FURTHER DISCUSSION

The kill command is useful for killing runaway or hung background processes. A runaway process is often caused by an infinite loop in a program. In any case the kill command can be used to remove a process from the system. A hung process may be caused by a disconnected device, such as a terminal, or printer that has hung. If a background process is waiting for input that will never arrive , you will need to kill the process.


NOTE:    
Because of the way UNIX handles process signaling, it is possible to have a process hang and not be able to kill it. This is caused by the program not being able to process its signal queue. Thus when you send a signal to the process to terminate it, the process never actually receives the signal. In these situations the system administrator may have to reboot the system to remove the process.

The following table lists the signals you can send to a process. Use the -l option to list out available signals and their corresponding names on your system. The symbolic names and numbers are not the same on all systems. The symbolic names in parenthesis are aliases.


Signal
Number
Symbolic
Name
Description

1 HUP Hang-up. The phone line disconnected.
2 INT Interrupt. Pressed the Delete key.
3 QUIT Quit. Pressed the Ctrl-\ key.
4 ILL Illegal instruction
5 TRAP Trace trap
6 IOT(ABRT) IOT instruction
7 EMT EMT instruction
8 FPE Floating point exception
9 KILL Kill process. Cannot be trapped
10 BUS Bus error
11 SEGV Segmentation violation
12 SYS Bad argument to system call
13 PIPE Write on a pipe with no one to read it
14 ALRM Alarm clock
15 TERM Software termination signal (default signal sent from kill)
16 USR1 User-defined signal 1
17 USR2 User-defined signal 2
18 CLD(CHLD) Death of a child
19 PWR Power fail restart
20 WINCH Window or mouse signal
21 URG Urgent socket condition
22 POLL(IO) Selectable event pending (asynchronous i/o)
23 STOP Stop process
24 TSTP Stop process requested from tty (keyboard)
25 CONT Continue after a stop
26 TTIN Background process requested tty (keyboard) input; stops process
27 TTOU Background process requested tty (terminal) output; stops process
28 VTALRM Virtual timer alarm
29 PROF Profiling timer alarm
30 XCPU Exceeded cpu limit
31 XFSZ Exceeded file size limit


NOTE:    
For a list of signals handled by your system use the kill -l command. If your system does not support the -l option, then try using the command grep SIG /usr/include/*/signal.h. Remember to strip off the SIG prefix.


Previous Table of Contents Next

Copyright Wordware Publishing, Inc.


Illustrated UNIX System V
Illustrated Unix System V/Bsd
ISBN: 1556221878
EAN: 2147483647
Year: N/A
Pages: 144
Authors: Robert Felps

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net