Kill (command)

Short description: Command in several OSes to terminate a process

killOriginal author(s)| AT&T Bell Laboratories

|

Developer(s)| Various open-source and commercial developers
Initial release| February 1973; 53 years ago (1973-02)
Operating system| Unix, Unix-like, Plan 9, Inferno, OS-9, Windows, ReactOS, Singularity, IBM i
Platform| Cross-platform
Type| Command
License| ReactOS: LGPL-2.1-or-later

In computing, `kill` is a command that is used in several popular operating systems to send signals to running processes.

## Contents

* 1 Implementations
* 1.1 Unix and Unix-like
* 1.1.1 Examples
* 1.1.2 Related programs
* 1.2 Microware OS-9
* 1.3 Microsoft Windows and ReactOS
* 1.3.1 Examples
* 1.4 Microsoft Singularity
* 1.4.1 Examples
* 1.5 Plan 9 from Bell Labs
* 1.5.1 Examples
* 1.6 Others
* 2 See also
* 3 References
* 4 Further reading
* 5 External links

## Implementations

### Unix and Unix-like

In Unix and Unix-like operating systems, `kill` is a command used to send a signal to a process. By default, the message sent is the termination signal, which requests that the process exit. 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, which sends signals to processes or process groups on the system, referenced by their numeric process IDs (PIDs) or process group IDs (PGIDs). `kill` is always provided as a standalone utility as defined by the POSIX standard. However, most shells have built-in `kill` commands that may slightly differ from it.[1][2]

There are many different signals that can be sent (see signal for a full list), although the signals in which users are generally most interested are SIGTERM ("terminate") and SIGKILL ("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 ("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, providing reliable ways of controlling the execution of processes. SIGKILL kills the process, and SIGSTOP pauses it until a SIGCONT ("continue") is received.[3]

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 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 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 signal. Some daemons, including Apache and Sendmail, re-read configuration files upon receiving SIGHUP, so the kill command may be used for this too. A SIGINT signal can be generated very simply by pressing in most Unix shells. It is also common for to be mapped to SIGTSTP ("terminal stop"), and for (backslash) to be mapped to SIGQUIT, which can force a program to do a core dump.

#### Related programs

* killall \- on some variations of Unix, such as Solaris, this utility is automatically invoked when the system is going through a shutdown. 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, and FreeBSD, 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 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 \- signals processes based on name and other attributes. It was introduced in Solaris 7 and has since been reimplemented for Linux, NetBSD and OpenBSD. pkill makes killing processes based on their name much more convenient: e.g. to kill a process named firefox without pkill (and without pgrep), one would have to type `kill `ps --no-headers -C firefox -o pid`` whereas with pkill, one can simply type `pkill firefox`.
* xkill - 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 the OS-9 shell. It is used to kill another process by process ID.[4]

Stop the process with the process ID "7":

$ kill 7

### Microsoft Windows and ReactOS

The `taskkill` command on Microsoft Windows

In Microsoft's command-line interpreter Windows PowerShell, `kill` is a predefined command alias for the `Stop-Process` cmdlet.

Microsoft Windows XP, Vista and 7 include the command `taskkill`[5] 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 Resource Kits available for Windows 98.[6]

GNU versions of `kill` have been ported via Cygwin and run inside of the Unix environment subsystem that Microsoft Windows Services for UNIX provides (Microsoft acquired Windows Services for Unix wholesale via their purchase of Softway Systems and their Interix product on September 17, 1999).[7]

The `taskkill` command on ReactOS

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.[8]

#### 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 { $_.Company -like "Microsoft*" -and $_.WorkingSet -gt 10MB } | kill -confirm

Confirm
Are you sure you want to perform this action?
Performing operation "Stop-Process" on Target "powershell (6832)".
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help (default is "Y"): A
PS C:\>

Here is a simpler example, which asks the process Explorer.exe 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's microkernel 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, 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 used by Plan 9, to kill the process.[9]

A similar command provided is called `slay`, which does the same but for processes that refuse to be killed this way.[9]

#### Examples

For example, to kill all instances of troff, one types:

kill troff | rc

### Others

The kill command has also been ported to the IBM i operating system.[10]

## See also

* Signal
* xkill
* killall
* pkill
* signal.h

## References

1. ↑ "Bash Reference Manual: Job Control Builtins". https://www.gnu.org/software/bash/manual/html_node/Job-Control-Builtins.html.
2. ↑ "zsh: 17. Shell Builtin Commands". http://zsh.sourceforge.net/Doc/Release/Shell-Builtin-Commands.html.
3. ↑ "<signal.h>". http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/signal.h.html.
4. ↑ Paul S. Dayan (1992). The OS-9 Guru - 1 : The Facts. Galactic Industrial Limited. ISBN 0-9519228-0-7.
5. ↑ "Taskkill". https://technet.microsoft.com/en-us/library/bb491009.aspx.
6. ↑ "Resource Kit Utilities - Windows '98 Resource Kit". http://www.activexperts.com/admin/reskit/reskit98/.
7. ↑ "GNU utilities for Win32". http://unxutils.sourceforge.net/.
8. ↑ reactos/taskkill.c at master · reactos/reactos · GitHub
9. ↑ 9.0 9.1 "UNIX to Plan 9 command translation". http://www.plan9.bell-labs.com/wiki/plan9/unix_to_plan_9_command_translation/.
10. ↑ IBM. "IBM System i Version 7.2 Programming Qshell" (in en). https://www.ibm.com/support/knowledgecenter/ssw_ibm_i_74/rzahz/rzahzpdf.pdf?view=kc.

## Further reading

* The Mac OS X Command Line: Unix Under the Hood. John Wiley & Sons. 2006. ISBN 978-0470113851.

## External links

* Command: `kill` – Commands & Utilities Reference, The Single UNIX Specification, Issue 7 from The Open Group
* System call: `kill` – System Interfaces Reference, The Single UNIX Specification, Issue 7 from The Open Group
* `kill(1)` – Plan 9 Programmer's Manual, Volume 1
* `kill(1)` – Inferno General commands Manual
* `kill(1)` – Linux User Commands Manual

* v
* t
* e

Unix command-line interface programs and shell builtins

File system|

* cat
* chmod
* chown
* chgrp
* cksum
* cmp
* cp
* dd
* du
* df
* file
* fuser
* ln
* ls
* mkdir
* mv
* pax
* pwd
* rm
* rmdir
* split
* tee
* touch
* type
* umask

Processes|

* at
* bg
* crontab
* fg
* kill
* nice
* ps
* time

User environment|

* env
* exit
* logname
* mesg
* talk
* tput
* uname
* who
* write

Text processing|

* awk
* basename
* comm
* csplit
* cut
* diff
* dirname
* ed
* ex
* fold
* head
* iconv
* join
* m4
* more
* nl
* paste
* patch
* printf
* sed
* sort
* strings
* tail
* tr
* uniq
* vi
* wc
* xargs

Shell builtins|

* alias
* cd
* echo
* test
* unset
* wait

Searching|

* find
* grep

Documentation|

* man

Software development|

* ar
* ctags
* lex
* make
* nm
* strip
* yacc

Miscellaneous|

* bc
* cal
* expr
* lp
* od
* sleep
* true and false

* Categories
* Standard Unix programs
* Unix SUS2008 utilities
* List

* v
* t
* e

Windows command-line programs and shell builtins

* COMMAND.COM
* Command Prompt
* Windows PowerShell
* Recovery Console

File system navigation|

* cd (chdir)
* dir
* popd
* pushd
* tree

File management|

* attrib
* cacls
* cipher
* compact
* copy
* del (erase)
* deltree
* expand
* icacls
* makecab
* mkdir (md)
* mklink
* move
* recover
* ren (rename)
* replace
* rmdir (rd)
* robocopy
* tar
* xcopy

Disk management|

* chkdsk
* convert
* defrag
* diskcomp
* diskcopy
* diskpart
* drvspace
* fdisk
* format
* label
* manage-bde
* subst
* scandisk
* sys
* vol
* vssadmin

Processes|

* at
* exit
* kill
* powercfg
* runas
* sc
* schtasks
* shutdown
* start
* taskkill
* tasklist

Registry|

* assoc
* ftype
* reg
* regini
* regsvr32

User environment|

* date
* mode
* path
* set
* setx
* time
* title
* ver
* whoami

File contents|

* comp
* edit
* edlin
* fc
* find
* findstr
* print
* type

Scripting|

* choice
* clip
* cscript
* doskey
* echo
* for
* forfiles
* goto
* if
* more
* pause
* prompt
* rem
* timeout

Networking|

* arp
* BITSAdmin
* cURL
* getmac
* hostname
* ipconfig
* net
* netsh
* netstat
* nslookup
* PathPing
* ping
* route
* scp
* sftp
* ssh
* ssh-add
* ssh-agent
* ssh-keygen
* ssh-keyscan
* tracert
* winrm
* winrs

Maintenance and care|

* driverquery
* eventcreate
* eventtriggers
* msiexec
* ntbackup
* sfc
* systeminfo
* w32tm
* WBAdmin
* winsat
* wmic

Boot management|

* bcdedit
* bootcfg
* fixboot
* fixmbr

Software development|

* debug
* exe2bin
* QBasic

Miscellaneous|

* cls
* dism
* dpath
* gpupdate
* help
* MSCDEX
* pentnt
* wsl

* List of DOS commands
* Environment variables

0.00

(0 votes)

Original source: https://en.wikipedia.org/wiki/Kill (command). Read more

|

Retrieved from "https://handwiki.org/wiki/index.php?title=Software:Kill_(command)&oldid=788240"
*[v]: View this template
*[t]: Discuss this template
*[e]: Edit this template