Процестерді тоқтату командасы және «kill» командасы туралы
Kill (command)
Команда "kill": аяқтау сигналы жіберу арқылы процестерді басқару. Unix және басқа да ОС-де процестерді тоқтату үшін қолданылады. PID/PGID арқылы сигнал жіберу.
Ағылшыншамен салыстырыңыз: абзацты басыңыз — түпнұсқа терезеде ашылады. Абзац астындағы EN түймесі оны мәтін ішінде көрсетеді.
Мазмұны
Кіріспе
Бірнеше операциялық жүйеде процесті тоқтату командасы
Command in several OSes to terminate a process
2016 жылғы британдық ғылыми-фантастикалық триллер фильмі
the 2016 British science fiction thriller film
Компьютерде kill – бірнеше танымал операциялық жүйеде іске қосылған процестерге сигнал жіберу үшін қолданылатын команда.
In computing, kill is a command that is used in several popular operating systems to send signals to running processes.
Unix және Unix-қа ұқсас
Unix және Unix-қа ұқсас операциялық жүйелерде kill – процеске сигнал жіберу үшін қолданылатын команда. Дәстүрлі түрде, жіберілетін хабарлама – процестің аяқталуын сұрайтын тоқтату сигналы. Бірақ «өлтіру» термині шартты, себебі жіберілген сигнал процесті тоқтатумен байланысты болмауы мүмкін. Kill командасы – жүйелік kill шақыруының орауышы, ол жүйедегі процестерге немесе процестер тобына олардың сандық процестер идентификаторы (PID) немесе процестер тобының идентификаторы (PGID) арқылы сигналдарды жібереді. Kill командасы POSIX стандартында анықталған дербес құрал ретінде әрқашан ұсынылады. Дегенмен, көптеген қабықшаларда (shell) одан сәл өзгеше kill командалары бар. Жіберуге болатын көптеген сигналдар бар (толық тізім үшін signal қараңыз), бірақ пайдаланушыларды ең көп қызықтыратындары SIGTERM («тоқтату») және SIGKILL («өлтіру»). Дәстүрлі сигнал SIGTERM болып табылады. Бұл сигналды өңдейтін бағдарламалар, тоқтату алдында конфигурациялық ақпаратты файлға сақтау сияқты, пайдалы тазалау операцияларын орындай алады. Алайда, көптеген бағдарламалар осы сигналға арналған арнайы өңдеушіні іске қоспайды, сондықтан әдепкі сигнал өңдеушісі шақырылады. Кейде тіпті арнайы өңдеушісі бар процесс те сигналды дұрыс өңдеуге кедергі келтіретін жағдайға түсуі мүмкін. SIGKILL және SIGSTOP («тоқтату») сигналдарын қоспағанда, барлық сигналдарды процесс «ұстап ала алады», яғни бағдарлама осы сигналдарды алғанда арнайы функция шақырылуы мүмкін. SIGKILL және SIGSTOP екі ерекшелік жүйе ядросымен ғана көрінеді, процестердің орындалуын басқарудың сенімді жолын ұсынады. SIGKILL процесті тоқтатады, ал SIGSTOP SIGCONT («жалғастыру») сигналы алынғанға дейін оны тоқтатады. Unix рұқсатсыз пайдаланушылардың басқа процестерді тоқтатуына жол бермеу үшін қауіпсіздік механизмдерін қамтамасыз етеді. Бір процесс екінші процеске сигнал жіберу үшін, сигнал жіберуші процестің иесі қабылдаушы процестің иесімен бірдей болуы керек немесе супер пайдаланушы болуы тиіс. Барлық қолжетімді сигналдардың әр түрлі атаулары бар және олар белгілі бір сандарға сәйкес келеді. Сандар мен сигналдар арасындағы нақты сәйкестік Unix жүйесінің әртүрлі нұсқаларында өзгеше болуы мүмкін. SIGTERM көбінесе 15 санымен, ал SIGKILL көбінесе 9 санымен нөмірленеді.
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. 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.
Қатысушы бағдарламалар
Unix-тің кейбір нұсқаларында, мысалы Solaris-те, бұл құрал жүйе өшіріліп жатқанда автоматты түрде іске қосылады. Ол жоғарыдағы kill командасына ұқсас, бірақ жеке процеске сигнал жіберудің орнына, сигнал жүйедегі барлық процестерге жіберіледі. Дегенмен, IRIX, Linux және FreeBSD сияқты басқаларында, өлтіруге тиіс процестің (немесе процестердің) атын көрсететін аргумент беріледі. Мысалы, xmms арқылы іске қосылған XMMS музыка ойнатқышының бір данасын жою үшін пайдаланушы killall xmms командасын орындайды. Бұл xmms деп аталған барлық процестерді тоқтатады және Solaris сияқты жүйелерде kill `pidof xmms` командасына тең келеді. pkill процестерді аты мен басқа да атрибуттары бойынша белгілейді. Ол алғаш рет Solaris 7-де пайда болды, кейін Linux, NetBSD және OpenBSD үшін қайта іске асырылды. pkill процестерді аты бойынша тоқтатуды әлдеқайда ыңғайлы етеді: мысалы, pkill және pgrep қолданбастан тыс firefox деп аталған процесті тоқтату үшін kill `ps no headers C firefox o pid` деп теру керек, ал pkill-мен жай ғана pkill firefox деп теру жеткілікті. xkill егер ешқандай параметрлерсіз шақырылса, тышқан курсоры жебеден "x" белгісіне өзгереді және пайдаланушы X серверінің терезенің иесіне қосылысын жабу үшін терезені басу арқылы мәжбүрлей алады. Бұл процесс X серверімен байланысы үзілгенін анықтағанда тоқтатылуына себеп болады.
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.
Microsoft Windows және ReactOS
Microsoft-тың Windows PowerShell командалық жол интерпретаторында kill – Stop Process cmdlet командасының алдын ала анықталған псевдонимдерінің бірі. Microsoft Windows XP, Vista және 7 жүйелері процестерді аяқтау үшін taskkill командасын қамтиды. Бұл команданың қалыпты синтаксисі: taskkill /im "IMAGENAME". Windows 98 үшін қолжетімді Microsoft Windows Resource Kits-тің бірнеше нұсқасында "қолдаусыз" kill нұсқасы да бар болған. GNU-ның kill нұсқалары Cygwin арқылы жүзеге асырылды және Microsoft Windows Services for UNIX қамтамасыз ететін Unix ортасының ішкі жүйесінде жұмыс істейді (Microsoft 1999 жылдың 17 қыркүйегінде Softway Systems және олардың Interix өнімін сатып алып, Windows Services for Unix құқығын толығымен иеленді). ReactOS-тың іске асырылуы Windows нұсқасына негізделген. Оны Эндрю Риди, Эндрю Нгуен және Хе Ян жасады. Ол LGPLv2.1 немесе одан кейінгі нұсқасымен лицензияланған.
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.
Microsoft бірлігі
Singularity қабығы, Microsoft Research-тің микроядролық операциялық жүйесі Singularity-нің стандартты қабығы, фондық процестерді тоқтату үшін «өшіру» командасын қамтиды.
Singularity shell, the standard shell for Microsoft Research's microkernel operating system Singularity includes a kill command to terminate background processes.
Белл зертханасының 9-жоспары
Белл Лабораториясының 9-жоспары бойынша, kill бағдарламасы процестерді тоқтатуды тікелей орындамайды, сондай-ақ процестердің идентификаторларын қабылдамайды. Оның орнына, ол процестердің нақты аттарын қабылдап, 9-жоспарында қолданылатын rc қабығына процестерді тоқтату командаларын шығарады. Осыған ұқсас slay командасы да бар, ол осылай жұмыс істейді, бірақ дәл осы тәсілмен тоқтатылудан бас тартатын процестер үшін қолданылады.
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. A similar command provided is called slay, which does the same but for processes that refuse to be killed this way.