In
computing
Computing is any goal-oriented activity requiring, benefiting from, or creating computing machinery. It includes the study and experimentation of algorithmic processes, and development of both hardware and software. Computing has scientific, e ...
,
kill
is a
command
Command may refer to:
Computing
* Command (computing), a statement in a computer language
* COMMAND.COM, the default operating system shell and command-line interpreter for DOS
* Command key, a modifier key on Apple Macintosh computer keyboards
* ...
that is used in several popular
operating system
An operating system (OS) is system software that manages computer hardware, software resources, and provides common services for computer programs.
Time-sharing operating systems schedule tasks for efficient use of the system and may also in ...
s to send
signals
In signal processing, a signal is a function that conveys information about a phenomenon. Any quantity that can vary over space or time can be used as a signal to share messages between observers. The ''IEEE Transactions on Signal Processing'' ...
to running
processes.
Implementations
Unix and Unix-like
In
Unix
Unix (; trademarked as UNIX) is a family of multitasking, multiuser computer operating systems that derive from the original AT&T Unix, whose development started in 1969 at the Bell Labs research center by Ken Thompson, Dennis Ritchie, and ot ...
and
Unix-like
A Unix-like (sometimes referred to as UN*X or *nix) operating system is one that behaves in a manner similar to a Unix system, although not necessarily conforming to or being certified to any version of the Single UNIX Specification. A Unix-li ...
operating systems,
kill
is a
command
Command may refer to:
Computing
* Command (computing), a statement in a computer language
* COMMAND.COM, the default operating system shell and command-line interpreter for DOS
* Command key, a modifier key on Apple Macintosh computer keyboards
* ...
used to send a
signal
In signal processing, a signal is a function that conveys information about a phenomenon. Any quantity that can vary over space or time can be used as a signal to share messages between observers. The '' IEEE Transactions on Signal Processing' ...
to a process. By default, the message sent is the
termination signal, which requests that the process
exit
Exit(s) may refer to:
Architecture and engineering
* Door
* Portal (architecture), an opening in the walls of a structure
* Emergency exit
* Overwing exit, a type of emergency exit on an airplane
* Exit ramp, a feature of a road interchange
...
. But ''kill'' is something of a misnomer; the signal sent may have nothing to do with process killing. The
kill
command is a
wrapper around the
kill()
system call
In computing, a system call (commonly abbreviated to syscall) is the programmatic way in which a computer program requests a service from the operating system on which it is executed. This may include hardware-related services (for example, acc ...
, which sends
signals
In signal processing, a signal is a function that conveys information about a phenomenon. Any quantity that can vary over space or time can be used as a signal to share messages between observers. The ''IEEE Transactions on Signal Processing'' ...
to processes or
process group
In a POSIX-conformant operating system, a process group denotes a collection of one or more processes.
Among other things, a process group is used to control the distribution of a signal;
when a signal is directed to a process group, the signal is ...
s on the system, referenced by their numeric
process ID
In computing, the process identifier (a.k.a. process ID or PID) is a number used by most operating system kernels—such as those of Unix, macOS and Windows—to uniquely identify an active process. This number may be used as a parameter in various ...
s (PIDs) or
process group
In a POSIX-conformant operating system, a process group denotes a collection of one or more processes.
Among other things, a process group is used to control the distribution of a signal;
when a signal is directed to a process group, the signal is ...
IDs (PGIDs).
kill
is always provided as a standalone utility as defined by the
POSIX
The Portable Operating System Interface (POSIX) is a family of standards specified by the IEEE Computer Society for maintaining compatibility between operating systems. POSIX defines both the system- and user-level application programming interf ...
standard. However, most
shells have
built-in
Built-in, builtin, or built in may refer to:
Computing
* Shell builtin, a command or a function executed directly in the shell itself
* Builtin function, in computer software and compiler theory
Other uses
* Built-in behavior, of a living organis ...
kill
commands that may slightly differ from it.
There are many different signals that can be sent (see ''
signal
In signal processing, a signal is a function that conveys information about a phenomenon. Any quantity that can vary over space or time can be used as a signal to share messages between observers. The '' IEEE Transactions on Signal Processing' ...
'' for a full list), although the signals in which users are generally most interested are
SIGTERM
Signals are standardized messages sent to a running program to trigger specific behavior, such as quitting or error handling. They are a limited form of inter-process communication (IPC), typically used in Unix, Unix-like, and other POSIX-comp ...
("terminate") and
SIGKILL
Signals are standardized messages sent to a running program to trigger specific behavior, such as quitting or error handling. They are a limited form of inter-process communication (IPC), typically used in Unix, Unix-like, and other POSIX-comp ...
("kill"). The default signal sent is SIGTERM. Programs that handle this signal can do useful cleanup operations (such as saving configuration information to a file) before quitting. However, many programs do not implement a special handler for this signal, and so a default signal handler is called instead. Other times, even a process that has a special handler has gone awry in a way that prevents it from properly handling the signal.
All signals except for SIGKILL and
SIGSTOP
In Unix and Unix-like operating systems, job control refers to control of jobs by a shell, especially interactively, where a "job" is a shell's representation for a process group. Basic job control features are the suspending, resuming, or termi ...
("stop") can be "intercepted" by the process, meaning that a special function can be called when the program receives those signals. The two exceptions SIGKILL and SIGSTOP are only seen by the host system's
kernel
Kernel may refer to:
Computing
* Kernel (operating system), the central component of most operating systems
* Kernel (image processing), a matrix used for image convolution
* Compute kernel, in GPGPU programming
* Kernel method, in machine learn ...
, providing reliable ways of controlling the execution of processes. SIGKILL kills the process, and SIGSTOP pauses it until a
SIGCONT
In Unix and Unix-like operating systems, job control refers to control of jobs by a shell, especially interactively, where a "job" is a shell's representation for a process group. Basic job control features are the suspending, resuming, or termina ...
("continue") is received.
Unix provides security mechanisms to prevent unauthorized users from killing other processes. Essentially, for a process to send a signal to another, the owner of the signaling process must be the same as the owner of the receiving process or be the
superuser.
The available signals all have different names, and are mapped to certain numbers. It is important to note that the specific mapping between numbers and signals can vary between Unix implementations. SIGTERM is often numbered 15 while SIGKILL is often numbered 9.
Examples
A process can be sent a
SIGTERM
Signals are standardized messages sent to a running program to trigger specific behavior, such as quitting or error handling. They are a limited form of inter-process communication (IPC), typically used in Unix, Unix-like, and other POSIX-comp ...
signal in four ways (the process ID is '1234' in this case):
kill 1234
kill -s TERM 1234
kill -TERM 1234
kill -15 1234
The process can be sent a
SIGKILL
Signals are standardized messages sent to a running program to trigger specific behavior, such as quitting or error handling. They are a limited form of inter-process communication (IPC), typically used in Unix, Unix-like, and other POSIX-comp ...
signal in three ways:
kill -s KILL 1234
kill -KILL 1234
kill -9 1234
Other useful signals include HUP, TRAP, INT,
SEGV and ALRM. HUP sends the
SIGHUP On POSIX-compliant platforms, SIGHUP ("signal hang up") is a signal sent to a process when its controlling terminal is closed. It was originally designed to notify the process of a serial line drop. SIGHUP is a symbolic constant defined in the h ...
signal. Some daemons, including
Apache
The Apache () are a group of culturally related Native American tribes in the Southwestern United States, which include the Chiricahua, Jicarilla, Lipan, Mescalero, Mimbreño, Ndendahe (Bedonkohe or Mogollon and Nednhi or Carrizaleño an ...
and
Sendmail
Sendmail is a general purpose internetwork email routing facility that supports many kinds of mail-transfer and delivery methods, including the Simple Mail Transfer Protocol (SMTP) used for email transport over the Internet.
A descendant of the ...
, re-read
configuration file
In computing, configuration files (commonly known simply as config files) are computer file, files used to configure the Parameter (computer programming), parameters and Initialization (programming), initial settings for some computer programs. T ...
s upon receiving SIGHUP, so the kill command may be used for this too. A
SIGINT
Signals intelligence (SIGINT) is intelligence-gathering by interception of '' signals'', whether communications between people (communications intelligence—abbreviated to COMINT) or from electronic signals not directly used in communication ...
signal can be generated very simply by pressing
in most
Unix shell
A Unix shell is a command-line Interpreter (computing), interpreter or shell (computing), shell that provides a command line user interface for Unix-like operating systems. The shell is both an interactive command language and a scripting langua ...
s. It is also common for
to be mapped to
SIGTSTP ("terminal stop"), and for
(backslash) to be mapped to
SIGQUIT
Signals are standardized messages sent to a running program to trigger specific behavior, such as quitting or error handling. They are a limited form of inter-process communication (IPC), typically used in Unix, Unix-like, and other POSIX-comp ...
, which can force a program to do a
core dump
In computing, a core dump, memory dump, crash dump, storage dump, system dump, or ABEND dump consists of the recorded state of the working memory of a computer program at a specific time, generally when the program has crashed or otherwise terminat ...
.
Related programs
*
killall
killall is a command line utility available on Unix-like systems. There are two very different implementations.
* The implementation supplied with genuine UNIX System V (including Solaris) and with the Linux sysvinit tools kills all processes ...
- on some variations of Unix, such as
Solaris
Solaris may refer to:
Arts and entertainment Literature, television and film
* ''Solaris'' (novel), a 1961 science fiction novel by Stanisław Lem
** ''Solaris'' (1968 film), directed by Boris Nirenburg
** ''Solaris'' (1972 film), directed by ...
, this utility is automatically invoked when the system is going through a
shutdown
Shutdown or shut down may refer to:
* Government shutdowns in the United States
* Shutdown (computing)
* Shutdown (economics)
* Shutdown (nuclear reactor)
Arts and entertainment Music
* "Shut Down" (The Beach Boys song), 1963
* ''Shut Down Volu ...
. It behaves much like the kill command above, but instead of sending a signal to an individual process, the signal is sent to all processes on the system. However, on others such as
IRIX,
Linux
Linux ( or ) is a family of open-source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991, by Linus Torvalds. Linux is typically packaged as a Linux distribution, which ...
, and
FreeBSD
FreeBSD is a free and open-source Unix-like operating system descended from the Berkeley Software Distribution (BSD), which was based on Research Unix. The first version of FreeBSD was released in 1993. In 2005, FreeBSD was the most popular ...
, an argument is supplied specifying the name of the process (or processes) to kill. For instance, to kill a process such as an instance of the
XMMS
X Multimedia System (XMMS) is an audio player for Unix-like systems released under a free software license.
History
XMMS was originally written as ''X11Amp'' by Peter and Mikael Alm in November 1997. The player was made to resemble Winamp, which ...
music player invoked by
xmms
, the user would run the command
killall xmms
. This would kill all processes named
xmms
, and is equivalent to
kill `pidof xmms`
on systems like Solaris.
*
pkill
(see ) is a command-line utility initially written for use with the Solaris 7 operating system in 1998. It has since been reimplemented for Linux and some BSDs.
As with the and commands, is used to send signals to processes. The command a ...
- signals processes based on name and other attributes. It was introduced in Solaris 7 and has since been reimplemented for Linux,
NetBSD and
OpenBSD
OpenBSD is a security-focused, free and open-source, Unix-like operating system based on the Berkeley Software Distribution (BSD). Theo de Raadt created OpenBSD in 1995 by forking NetBSD 1.0. According to the website, the OpenBSD project em ...
. pkill makes killing processes based on their name much more convenient: e.g. to kill a process named ''firefox'' without pkill (and without
pgrep
pgrep is a command-line utility initially written for use with the Solaris 7 operating system by Mike Shapiro. It has since been available in illumos and reimplemented for the Linux and BSDs (DragonFly BSD, FreeBSD, NetBSD, and OpenBSD). It sea ...
), one would have to type
kill `ps --no-headers -C firefox -o pid`
whereas with pkill, one can simply type
pkill firefox
.
*
xkill
Xkill is a utility software, utility program distributed with the X Window System that instructs the X server to forcefully terminate its connection to a client, thus "killing" the client. When run with no command line arguments, the program displa ...
- if called without any parameters, the mouse cursor changes from an arrow to an "x" icon, and the user can click on a window to force the X server to close the connection with the client owning the window. This often causes the process to terminate when it detects that its connection to the X server has been closed.
Microware OS-9
The
kill
command is also available as a
shell builtin
In computing, a shell builtin is a command or a function, called from a shell, that is executed directly in the shell itself, instead of an external executable program which the shell would load and execute.
Shell builtins work significantly fa ...
in the
OS-9
OS-9 is a family of real-time, process-based, multitasking, multi-user operating systems, developed in the 1980s, originally by Microware Systems Corporation for the Motorola 6809 microprocessor. It was purchased by Radisys Corp in 2001, an ...
shell. It is used to kill another process by process ID.
Example
Stop the process with the process ID "7":
$ kill 7
Microsoft Windows and ReactOS
In Microsoft's command-line interpreter
Windows PowerShell
PowerShell is a task automation and configuration management program from Microsoft, consisting of a command-line shell and the associated scripting language. Initially a Windows component only, known as Windows PowerShell, it was made open-so ...
,
kill
is a predefined
command alias for the
Stop-Process
cmdlet
PowerShell is a task automation and configuration management program from Microsoft, consisting of a command-line shell and the associated scripting language. Initially a Windows component only, known as Windows PowerShell, it was made open-sou ...
.
Microsoft Windows XP
Windows XP is a major release of Microsoft's Windows NT operating system. It was released to manufacturing on August 24, 2001, and later to retail on October 25, 2001. It is a direct upgrade to its predecessors, Windows 2000 for high-end and ...
,
Vista
Vista usually refers to a distant view.
Vista may also refer to:
Software
*Windows Vista, the line of Microsoft Windows client operating systems released in 2006 and 2007
* VistA, (Veterans Health Information Systems and Technology Architecture) ...
and
7 include the command
taskkill
to terminate processes. The usual syntax for this command is
taskkill /im "IMAGENAME"
. An "unsupported" version of
kill
was included in several releases of the
Microsoft Windows
Windows is a group of several proprietary graphical operating system families developed and marketed by Microsoft. Each family caters to a certain sector of the computing industry. For example, Windows NT for consumers, Windows Server for serv ...
Resource Kit Resource Kit is a term used by Microsoft for a set of software resources and documentation released for their software products, but which is not part of that product. Resource kits offer supplementary resources such as technical guidance, compatibi ...
s available for Windows 98.
GNU
GNU () is an extensive collection of free software (383 packages as of January 2022), which can be used as an operating system or can be used in parts with other operating systems. The use of the completed GNU tools led to the family of operat ...
versions of
kill
have been ported via
Cygwin and run inside of the Unix environment subsystem that
Microsoft Windows Services for UNIX
Windows Services for UNIX (SFU) is a discontinued software package produced by Microsoft which provided a Unix environment on Windows NT and some of its immediate successor operating-systems.
SFU 1.0 and 2.0 used the MKS Toolkit; starting with ...
provides (Microsoft acquired Windows Services for Unix wholesale via their purchase of Softway Systems and their
Interix
Interix was an optional, POSIX-conformant Unix subsystem for Windows NT operating systems. Interix was a component of Windows Services for UNIX, and a superset of the Microsoft POSIX subsystem. Like the POSIX subsystem, Interix was an environment ...
product on September 17, 1999).
The
ReactOS implementation is based on the Windows variant. It was developed by Andrew Riedi, Andrew Nguyen, and He Yang. It is licensed under the
LGPLv2.1 or later.
[reactos/taskkill.c at master · reactos/reactos · GitHub](_blank)
/ref>
Examples
Find all processes beginning with the letter "p" that were developed by Microsoft and use more than 10 MB of memory and kill them:
PS C:\> ps p* , where , kill -confirm
Confirm
Are you sure you want to perform this action?
Performing operation "Stop-Process" on Target "powershell (6832)".
Yes Yes to All No No to All Suspend Help (default is "Y"): A
PS C:\>
Here is a simpler example, which asks the process Explorer.exe
File Explorer, previously known as Windows Explorer, is a file manager application that is included with releases of the Microsoft Windows operating system from Windows 95 onwards. It provides a graphical user interface for accessing the file ...
to terminate:
PS C:\> taskkill /im explorer.exe
This example forces the process to terminate:
PS C:\> taskkill /f /im explorer.exe
Processes can also be killed by their PID number:
PS C:\> taskkill /pid 3476
Microsoft Singularity
Singularity shell, the standard shell for Microsoft Research
Microsoft Research (MSR) is the research subsidiary of Microsoft. It was created in 1991 by Richard Rashid, Bill Gates and Nathan Myhrvold with the intent to advance state-of-the-art computing and solve difficult world problems through technologi ...
's microkernel
In computer science, a microkernel (often abbreviated as μ-kernel) is the near-minimum amount of software that can provide the mechanisms needed to implement an operating system (OS). These mechanisms include low-level address space management, ...
operating system Singularity includes a kill
command to terminate background processes.
Examples
Stop the process with the name "SampleProcess":
Singularity>kill SampleProcess
Stop the process with the process identifier "42":
Singularity>kill 42
Plan 9 from Bell Labs
Under Plan 9 from Bell Labs
Plan 9 from Bell Labs is a distributed operating system which originated from the Computing Science Research Center (CSRC) at Bell Labs in the mid-1980s and built on UNIX concepts first developed there in the late 1960s. Since 2000, Plan 9 has be ...
, the kill program does not actually perform this termination, nor does it take process IDs. Rather, it takes the actual names of processes and outputs the commands for rc, the shell
Shell may refer to:
Architecture and design
* Shell (structure), a thin structure
** Concrete shell, a thin shell of concrete, usually with no interior columns or exterior buttresses
** Thin-shell structure
Science Biology
* Seashell, a hard o ...
used by Plan 9, to kill the process.
A similar command provided is called slay
, which does the same but for processes that refuse to be killed this way.
Examples
For example, to kill all instances of troff
troff (), short for "typesetter roff", is the major component of a document processing system developed by Bell Labs for the Unix operating system. troff and the related nroff were both developed from the original roff.
While nroff was inte ...
, one types:
kill troff , rc
Others
The command has also been ported to the IBM i operating system.
See also
* Signal
In signal processing, a signal is a function that conveys information about a phenomenon. Any quantity that can vary over space or time can be used as a signal to share messages between observers. The '' IEEE Transactions on Signal Processing' ...
* xkill
Xkill is a utility software, utility program distributed with the X Window System that instructs the X server to forcefully terminate its connection to a client, thus "killing" the client. When run with no command line arguments, the program displa ...
* killall
killall is a command line utility available on Unix-like systems. There are two very different implementations.
* The implementation supplied with genuine UNIX System V (including Solaris) and with the Linux sysvinit tools kills all processes ...
* pkill
(see ) is a command-line utility initially written for use with the Solaris 7 operating system in 1998. It has since been reimplemented for Linux and some BSDs.
As with the and commands, is used to send signals to processes. The command a ...
* signal.h
References
Further reading
*
External links
* Command:
* System call:
*
*
*
{{DEFAULTSORT:Kill (Command)
Unix SUS2008 utilities
Unix process- and task-management-related software
Plan 9 commands
Inferno (operating system) commands
IBM i Qshell commands
Process (computing)
Windows administration