Original author(s) | AT&T Bell Laboratories |
---|---|
Developer(s) | Various open-source and commercial developers |
Initial release | February 1973 |
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.
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.
A process can be sent a SIGTERM signal in four ways (the process ID is '1234' in this case):
kill1234kill-sTERM1234kill-TERM1234kill-151234
The process can be sent a SIGKILL signal in three ways:
kill-sKILL1234kill-KILL1234kill-91234
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 CTRL+C in most Unix shells. It is also common for CTRL+Z to be mapped to SIGTSTP ("terminal stop"), and for CTRL+\ (backslash) to be mapped to SIGQUIT, which can force a program to do a core dump.
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.kill `ps --no-headers -C firefox -o pid`
whereas with pkill, one can simply type pkill firefox
.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
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 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]
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-gt10MB}|kill -confirmConfirmAre 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"): APS C:\>
Here is a simpler example, which asks the process Explorer.exe to terminate:
PS C:\> taskkill/imexplorer.exe
This example forces the process to terminate:
PS C:\> taskkill/f/imexplorer.exe
Processes can also be killed by their PID number:
PS C:\> taskkill/pid3476
Singularity shell, the standard shell for Microsoft Research's microkernel operating system Singularity includes a kill
command to terminate background processes.
Stop the process with the name "SampleProcess":
Singularity>kill SampleProcess
Stop the process with the process identifier "42":
Singularity>kill 42
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]
For example, to kill all instances of troff, one types:
kill troff | rc
The kill command has also been ported to the IBM i operating system. [10]
In computing, at
is a command in Unix-like operating systems, Microsoft Windows, and ReactOS used to schedule commands to be executed once, at a particular time in the future.
A background process is a computer process that runs behind the scenes and without user intervention. Typical tasks for these processes include logging, system monitoring, scheduling, and user notification.
dd is a command-line utility for Unix, Plan 9, Inferno, and Unix-like operating systems and beyond, the primary purpose of which is to convert and copy files. On Unix, device drivers for hardware and special device files appear in the file system just like normal files; dd can also read and/or write from/to these files, provided that function is implemented in their respective driver. As a result, dd can be used for tasks such as backing up the boot sector of a hard drive, and obtaining a fixed amount of random data. The dd program can also perform conversions on the data as it is copied, including byte order swapping and conversion to and from the ASCII and EBCDIC text encodings.
In most Unix and Unix-like operating systems, the ps
program displays the currently-running processes. The related Unix utility top
provides a real-time view of the running processes.
In computing, echo
is a command that outputs the strings that are passed to it as arguments. It is a command available in various operating system shells and typically used in shell scripts and batch files to output status text to the screen or a computer file, or as a source part of a pipeline.
In computing, netstat
is a command-line network utility that displays network connections for Transmission Control Protocol, routing tables, and a number of network interface and network protocol statistics. It is available on Unix, Plan 9, Inferno, and Unix-like operating systems including macOS, Linux, Solaris and BSD. It is also available on IBM OS/2 and on Microsoft Windows NT-based operating systems including Windows XP, Windows Vista, Windows 7, Windows 8 and Windows 10.
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-compliant operating systems.
nohup is a POSIX command which means "no hang up". Its purpose is to execute a command such that it ignores the HUP (hangup) signal and therefore does not stop when the user logs out.
On POSIX-compliant platforms, SIGHUP 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 header file signal.h
.
In computing, tee
is a command in command-line interpreters (shells) using standard streams which reads standard input and writes it to both standard output and one or more files, effectively duplicating its input. It is primarily used in conjunction with pipes and filters. The command is named after the T-splitter used in plumbing.
test is a command-line utility found in Unix, Plan 9, and Unix-like operating systems that evaluates conditional expressions. test was turned into a shell builtin command in 1981 with UNIX System III and at the same time made available under the alternate name [.
In Windows NT operating systems, a Windows service is a computer program that operates in the background. It is similar in concept to a Unix daemon. A Windows service must conform to the interface rules and protocols of the Service Control Manager, the component responsible for managing Windows services. It is the Services and Controller app, services.exe, that launches all the services and manages their actions, such as start, end, etc.
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 terminating of all processes in the job/process group; more advanced features can be performed by sending signals to the job. Job control is of particular interest in Unix due to its multiprocessing, and should be distinguished from job control generally, which is frequently applied to sequential execution.
In computing, tasklist
is a command available in Microsoft Windows and in the AROS shell.
In the C Standard Library, signal processing defines how a program handles various signals while it executes. A signal can report some exceptional behavior within the program, or a signal can report some asynchronous event outside the program.
The Unix command fuser
is used to show which processes are using a specified computer file, file system, or Unix socket.
od
is a command on various operating systems for displaying ("dumping") data in various human-readable output formats. The name is an acronym for "octal dump" since it defaults to printing in the octal data format.
In computing, help
is a command in various command line shells such as COMMAND.COM
, cmd.exe
, Bash, qshell, 4DOS/4NT, Windows PowerShell, Singularity shell, Python, MATLAB and GNU Octave. It provides online information about available commands and the shell environment.
In computing, copy
is a command in various operating systems. The command copies computer files from one directory to another.
To shut down or power off a computer is to remove power from a computer's main components in a controlled way. After a computer is shut down, main components such as CPUs, RAM modules and hard disk drives are powered down, although some internal components, such as an internal clock, may retain power.