Movatterモバイル変換


[0]ホーム

URL:


Jump to content
WikipediaThe Free Encyclopedia
Search

kill (command)

From Wikipedia, the free encyclopedia
(Redirected fromTaskkill)
Command in several OSes to terminate a process
For the 2016 British science fiction thriller film, seeKill Command.
kill
Original author(s)AT&T Bell Laboratories
Developer(s)Variousopen-source andcommercial developers
Initial releaseFebruary 1973; 52 years ago (1973-02)
Operating systemUnix,Unix-like,Plan 9,Inferno,OS-9,Windows,ReactOS,Singularity,IBM i
PlatformCross-platform
TypeCommand
LicenseReactOS:LGPL-2.1-or-later

Incomputing,kill is acommand that is used in several popularoperating systems to sendsignals to runningprocesses.

Implementations

[edit]

Unix and Unix-like

[edit]

InUnix andUnix-like operating systems,kill is acommand used to send asignal to a process. By default, the message sent is thetermination signal, which requests that the processexit. Butkill is something of a misnomer; the signal sent may have nothing to do with process killing. Thekill command is awrapper around thekill()system call, which sendssignals to processes orprocess groups on the system, referenced by their numericprocess IDs (PIDs) orprocess group IDs (PGIDs).kill is always provided as a standalone utility as defined by thePOSIX standard. However, mostshells havebuilt-inkill commands that may slightly differ from it.[1][2]

There are many different signals that can be sent (seesignal for a full list), although the signals in which users are generally most interested areSIGTERM ("terminate") andSIGKILL ("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 andSIGSTOP ("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'skernel, providing reliable ways of controlling the execution of processes. SIGKILL kills the process, and SIGSTOP pauses it until aSIGCONT ("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 thesuperuser.

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

[edit]

A process can be sent aSIGTERM signal in four ways (the process ID is '1234' in this case):

kill1234kill-sTERM1234kill-TERM1234kill-151234

The process can be sent aSIGKILL signal in three ways:

kill-sKILL1234kill-KILL1234kill-91234

Other useful signals include HUP, TRAP, INT,SEGV and ALRM. HUP sends theSIGHUP signal. Some daemons, includingApache andSendmail, re-readconfiguration files upon receiving SIGHUP, so the kill command may be used for this too. ASIGINT signal can be generated very simply by pressingCTRL+C in mostUnix shells. It is also common forCTRL+Z to be mapped toSIGTSTP ("terminal stop"), and forCTRL+\ (backslash) to be mapped toSIGQUIT, which can force a program to do acore dump.

Related programs

[edit]
  • killall - on some variations of Unix, such asSolaris, this utility is automatically invoked when the system is going through ashutdown. 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 asIRIX,Linux, andFreeBSD, 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 theXMMS music player invoked byxmms, the user would run the commandkillall xmms. This would kill all processes namedxmms, and is equivalent tokill `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 andOpenBSD. pkill makes killing processes based on their name much more convenient: e.g. to kill a process namedfirefox without pkill (and withoutpgrep), one would have to typekill `ps --no-headers -C firefox -o pid` whereas with pkill, one can simply typepkill 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

[edit]

Thekill command is also available as ashell builtin in theOS-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

[edit]
Thetaskkill command onMicrosoft Windows

In Microsoft's command-line interpreterWindows PowerShell,kill is a predefinedcommand alias for theStop-Processcmdlet.

Microsoft Windows XP,Vista and7 include the commandtaskkill[5] to terminate processes. The usual syntax for this command istaskkill /im "IMAGENAME". An "unsupported" version ofkill was included in several releases of theMicrosoft WindowsResource Kits available for Windows 98.[6]

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

Thetaskkill command onReactOS

TheReactOS implementation is based on the Windows variant. It was developed by Andrew Riedi, Andrew Nguyen, and He Yang. It is licensed under theLGPLv2.1 or later.[8]

Examples

[edit]

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:\>psp*|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 processExplorer.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 theirPID number:

PS C:\>taskkill/pid3476

Microsoft Singularity

[edit]

Singularity shell, the standard shell forMicrosoft Research'smicrokernel operating systemSingularity includes akill command to terminate background processes.

Examples

[edit]

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

[edit]

UnderPlan 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 forrc, theshell used by Plan 9, to kill the process.[9]

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

Examples

[edit]

For example, to kill all instances oftroff, one types:

kill troff | rc

Others

[edit]

Thekill command has also been ported to theIBM i operating system.[10]

See also

[edit]

References

[edit]
  1. ^"Bash Reference Manual: Job Control Builtins".The GNU Project. Retrieved2015-02-24.
  2. ^"zsh: 17. Shell Builtin Commands". Retrieved2015-02-24.
  3. ^"<signal.h>".The Open Group Base Specifications Issue 7. Retrieved2015-02-24.
  4. ^Paul S. Dayan (1992).The OS-9 Guru - 1 : The Facts. Galactic Industrial Limited.ISBN 0-9519228-0-7.
  5. ^"Taskkill".Microsoft TechNet. Retrieved2015-02-24.
  6. ^"Resource Kit Utilities - Windows '98 Resource Kit".ActiveXperts Software. Archived fromthe original on 2019-05-25. Retrieved2015-02-24.
  7. ^"GNU utilities for Win32". Archived fromthe original on 2006-02-09. Retrieved2015-02-24.
  8. ^reactos/taskkill.c at master · reactos/reactos · GitHub
  9. ^ab"UNIX to Plan 9 command translation".Plan 9 wiki. Archived fromthe original on 2008-09-05. Retrieved2015-02-24.
  10. ^IBM."IBM System i Version 7.2 Programming Qshell"(PDF).IBM. Retrieved2020-09-05.

Further reading

[edit]

External links

[edit]
The WikibookGuide to Unix has a page on the topic of:Commands
File system
Processes
User environment
Text processing
Shell builtins
Searching
Documentation
Software development
Miscellaneous
File system
Processes
User environment
Text processing
Shell builtins
Networking
Searching
Software development
Miscellaneous
Ecosystem
Interpreters
Terminals
File system navigation
File management
Archiving
Disk management
Processes
Registry
User environment
File contents
Scripting
Networking
Maintenance and care
Boot management
Software development
Miscellaneous
Retrieved from "https://en.wikipedia.org/w/index.php?title=Kill_(command)&oldid=1234038717#Microsoft_Windows_and_ReactOS"
Categories:
Hidden categories:

[8]ページ先頭

©2009-2025 Movatter.jp