ArticleslgStudy

computer science

Kill (command)

Kill (command) is a computer science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Kill (command) rather than just read about it. In short: In computing, kill is a command that is used in several popular operating systems to send signals to running processes. Implementations Unix and Unix-like In Unix and Unix-like operating systems, kill is a command used to send a signal to a process.

Kill (command) — main illustration
Kill (command) — illustration

Key takeaways

  • Kill (command) belongs to computer science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Kill (command) to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Kill (command) from memory before moving on to harder problems.

Reference excerpt

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

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. 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. 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. 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):

The process can be sent a SIGKILL signal in three ways:

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.

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. On some systems 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. It only functions on systems running X11; for example, it does not work with a Wayland compositor.

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. Stop the process with the process ID "7":

Microsoft Windows and ReactOS

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 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. 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).

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.

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:

Here is a simpler example, which asks the process Explorer.exe to terminate:

This example forces the process to terminate:

Processes can also be killed by their PID number:

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":

Stop the process with the process identifier "42":

… excerpt ends here. Continue reading the full article.

Illustrations

Kill (command): The taskkill command on ReactOS
The taskkill command on ReactOS

Worked examples

Example 1 — a first encounter with Kill (command)

Start with the simplest possible case. Write down what Kill (command) claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In computer science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Kill (command) before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Kill (command) ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Kill (command)

In research
Kill (command) appears in computer science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Kill (command) in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Kill (command) is common in secondary-school and first-year university syllabi. It links to neighbouring topics IBM i Qshell commands, Inferno (operating system) commands, Plan 9 commands, so understanding it makes those chapters shorter.
In everyday life
Look for Kill (command) outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Kill (command)” →

How to study Kill (command) in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Kill (command) means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Kill (command) out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Kill (command) in simple terms?

In computing, kill is a command that is used in several popular operating systems to send signals to running processes. Implementations Unix and Unix-like In Unix and Unix-like operating systems, kill is a command used to send a signal to a process.

Why does Kill (command) matter?

Because it connects several computer science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Kill (command)?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Kill (command).

Tags

  • IBM i Qshell commands
  • Inferno (operating system) commands
  • Plan 9 commands
  • Process (computing)
  • Unix SUS2008 utilities
  • Unix process- and task-management-related software
  • Windows administration
  • Windows commands

Keep exploring