kill 명령어 (AIX 5.3·6.1)
https://archive.horanglab.com/posts/aix-cmd-kill
핵심 정리
- 실행 중인 프로세스에 신호를 보냅니다. 기본 신호는 SIGTERM(15)이며 보통 프로세스를 끝냅니다.
- 신호는
-s KILL,-KILL,-9처럼 이름이나 번호로 지정합니다. 이름은 대소문자와 상관없고SIG접두사를 빼고 씁니다. - PID가 양수면 그 프로세스, 0이면 보낸 사람과 같은 프로세스 그룹 전체, -1이면 보낸 사람의 실효 사용자가 가진 모든 프로세스, -1이 아닌 음수면 그 절댓값의 프로세스 그룹에 보냅니다.
kill -l은 신호 이름을 나열하고,kill -l 종료상태는 그 프로세스를 끝낸 신호의 이름을 보여 줍니다.- 신호 번호 0은 PID가 유효한지 검사만 합니다. root는 아무 프로세스나, 일반 사용자는 자기가 시작한 프로세스만 끝낼 수 있습니다.
- AIX 5.3과 6.1 문서의 내용이 같습니다.
| 항목 | 내용 |
|---|---|
| 버전 | AIX 5.3, AIX 6.1 (두 버전 내용 같음) |
| 원문 | IBM Commands Reference — 5.3 Volume 3, 6.1 Volume 3 |
| 파일 | /usr/bin/kill, /usr/include/sys/signal.h |
| 관련 명령어 | ps, ksh, csh |
목적
실행 중인 프로세스에 신호를 보냅니다.
영어 원문
Sends a signal to running processes.
구문
프로세스에 신호를 보낼 때:
kill [ -s { SignalName | SignalNumber } ] ProcessID ...
kill [ -SignalName | -SignalNumber ] ProcessID ...
신호 이름을 나열할 때:
kill -l [ ExitStatus ]
설명
kill 명령은 실행 중인 프로세스에 신호를 보냅니다(기본은 SIGTERM). 이 기본 동작은 보통 프로세스를 끝냅니다. 프로세스를 끝내려면 ProcessID 변수에 프로세스 ID(PID)를 지정합니다. 셸은 백그라운드로 돌리는 프로세스마다 PID를 알려 줍니다(파이프라인으로 여러 프로세스를 시작하면 마지막 프로세스의 번호를 알려 줌). ps 명령으로 명령의 프로세스 ID를 찾을 수도 있습니다.
root 사용자는 kill로 어떤 프로세스든 끝낼 수 있습니다. root가 아니면 자신이 시작한 프로세스만 끝낼 수 있습니다.
SignalName은 대소문자를 가리지 않으며 SIG 접두사 없이 씁니다.
SignalNumber가 0이면 지정한 PID가 유효한지 확인합니다.
영어 원문
The kill command sends a signal (by default, the SIGTERM signal) to a running process. This default action normally stops processes. If you want to stop a process, specify the process ID (PID) in the ProcessID variable. The shell reports the PID of each process that is running in the background (unless you start more than one process in a pipeline, in which case the shell reports the number of the last process). You can also use the ps command to find the process ID number of commands.
A root user can stop any process with the kill command. If you are not a root user, you must have initiated the process that you want to stop.
SignalName is recognized in a case-independent fashion, without the SIG prefix.
If the specified SignalNumber is 0, the kill command checks the validity of the specified PID.
플래그
| 플래그 | 설명 |
|---|---|
-s {SignalName | SignalNumber} |
신호를 번호나 이름으로 지정합니다. 예를 들어 SIGKILL은 -9나 KILL입니다. |
-SignalName |
신호 이름을 지정합니다(예: HUP). |
-SignalNumber |
신호 번호를 지정합니다. 이 형식에서 기본 신호로 음수 PID를 지정하려면 신호 자리에 --를 써야 합니다. 아니면 첫 피연산자를 SignalNumber로 해석합니다. |
| ProcessID | 신호를 보낼 프로세스나 프로세스 그룹을 나타내는 10진 정수입니다(아래 표). |
-l |
지원하는 신호 이름을 모두 나열합니다. |
-l ExitStatus |
SIG 접두사를 뺀 신호 이름을 나열합니다. ExitStatus가 10진 정수면 그 번호의 신호 이름을, 신호로 끝난 프로세스의 종료 상태 값이면 그 프로세스를 끝낸 신호의 이름을 보여 줍니다. |
ProcessID 값에 따라 신호를 받는 프로세스:
| PID | 신호를 받는 프로세스 |
|---|---|
| 양수 | 프로세스 ID가 PID인 프로세스 |
| 0 | 프로세스 그룹 ID가 보낸 사람의 프로세스 그룹 ID와 같은 모든 프로세스(PID 0과 1은 제외) |
| -1 | 보낸 사람의 실효 사용자가 가진 모든 프로세스(PID 0과 1은 제외) |
| -1이 아닌 음수 | 프로세스 그룹 ID가 PID의 절댓값인 모든 프로세스 |
영어 원문
-s{SignalName|SignalNumber} — Specifies the signal as a signal number or a signal name, such as -9 or KILL for the SIGKILL signal.-SignalName — Specifies a signal name, such as HUP.-SignalNumber — Specifies a signal number. Note: To specify the negative PID with the default signal in this syntax, you must specify- -as a signal. Otherwise the first operand is interpreted as a SignalNumber.- ProcessID — Specifies a decimal integer that represents a process or process group to be signaled. If PID is a positive value, the kill command sends the process whose process ID is equal to the PID. If the PID value is 0, the kill command sends the signal to all processes that have a process group ID equal to the process group ID of the sender. The signal is not sent to processes with a PID of 0 or 1. If the PID is -1, the kill command sends the signal to all processes owned by the effective user of the sender. The signal is not sent to processes with a PID of 0 or 1. If it is a negative number but not -1, the kill command sends the signal to all processes that have a process group ID equal to the absolute value of the PID.
-l— Lists all signal names that are supported by the implementation-lExitStatus — Lists signal names that are stripped of the common SIG prefix. If ExitStatus is a decimal integer value, the signal name corresponding to that signal is displayed. If ExitStatus is a value of the exit status corresponding to a process that was terminated by a signal, the signal name corresponding to the signal that terminated the process is displayed.
종료 상태
| 값 | 뜻 |
|---|---|
| 0 | ProcessID 피연산자마다 맞는 프로세스를 적어도 하나 찾았고, 그중 적어도 하나에 신호를 잘 보냈습니다. |
| 0보다 큼 | 오류가 났습니다. |
영어 원문
This command returns the following exit values:
- 0 — At least one matching process was found for each ProcessID operand, and the specified signal was successfully processed for at least one matching process.
>0— An error occurred.
예제
- 특정 프로세스를 끝냅니다. 기본 신호 SIGTERM을 보내 프로세스
1095를 끝냅니다. 프로세스가 SIGTERM을 무시하거나 따로 처리하도록 해 두었으면 끝나지 않을 수 있습니다.
kill 1095
- 기본 신호를 무시하는 프로세스 여러 개를 끝냅니다. 프로세스
2098과1569에 신호 9(SIGKILL)를 보냅니다. SIGKILL은 보통 무시하거나 가로챌 수 없는 특별한 신호입니다.
kill -kill 2098 1569
- 자신의 프로세스를 모두 끝내고 로그오프합니다. 보낸 사람과 프로세스 그룹 ID가 같은 모든 프로세스에 SIGKILL을 보냅니다. 셸도 SIGKILL을 무시할 수 없으므로 로그인 셸이 끝나 로그오프됩니다.
kill -kill 0
- 자신이 가진 모든 프로세스를 끝냅니다. 다른 워크스테이션에서 시작했거나 다른 프로세스 그룹에 속한 것까지, 실효 사용자가 가진 모든 프로세스에 SIGKILL을 보냅니다. 요청한 인쇄 작업이 출력 중이면 그것도 멈춥니다.
kill -9 -1
- 다른 신호 코드를 보냅니다. SIGUSR1을 비롯한 많은 신호는 프로세스를 끝내지 않으므로
kill이라는 이름은 오해를 부를 수 있습니다. SIGUSR1에 대한 동작은 그 응용 프로그램이 정합니다.
kill -USR1 1103
참고: 이 형식으로 신호 15(SIGTERM)를 보내려면 -15나 TERM을 명시해야 합니다.
영어 원문
- To stop a given process, enter the following command:
kill 1095
This stops process 1095 by sending it the default SIGTERM signal. Note that process 1095 might not actually stop if it has made special arrangements to ignore or override the SIGTERM signal.
- To stop several processes that ignore the default signal, enter the following command:
kill -kill 2098 1569
This sends signal 9, the SIGKILL signal, to processes 2098 and 1569. The SIGKILL signal is a special signal that normally cannot be ignored or overridden.
- To stop all of your processes and log yourself off, enter the following command:
kill -kill 0
This sends signal 9, the SIGKILL signal, to all processes that have a process group ID equal to the senders process group ID. Because the shell cannot ignore the SIGKILL signal, this command also stops the login shell and logs you off.
- To stop all processes that you own, enter the following command:
kill -9 -1
This command sends signal 9, the SIGKILL signal, to all processes that are owned by the effective user, even those processes that are started at other workstations and that belong to other process groups. If a listing that you requested is being printed, it is also stopped.
- To send a different signal code to a process, enter the following command:
kill -USR1 1103
The name of the kill command is misleading because many signals, including SIGUSR1, do not stop processes. The action that is taken on SIGUSR1 is defined by the particular application you are running.
Note: To send signal 15, the SIGTERM signal with this form of the kill command, you must explicitly specify -15 or TERM.
파일
| 파일 | 설명 |
|---|---|
/usr/include/sys/signal.h |
신호 이름이 정의돼 있습니다. |
관련 명령어: ksh, csh
영어 원문
- /usr/include/sys/signal.h — Specifies signal names.
Related reference:
- ksh Command
Related information:
- csh command
- kill subroutine
- sigaction subroutine
리눅스(GNU)와 다른 점
리눅스의 kill(bash 내장과 procps)도 같은 구문을 씁니다. 다만 신호 번호가 다른 것이 있어 숫자보다 이름을 쓰는 것이 안전합니다.
| 신호 | AIX 번호 | 리눅스(x86) 번호 |
|---|---|---|
| SIGBUS | 10 | 7 |
| SIGUSR1 | 30 | 10 |
| SIGUSR2 | 31 | 12 |
| SIGCHLD | 20 | 17 |
| SIGSTOP | 17 | 19 |
| SIGCONT | 19 | 18 |
HUP(1), INT(2), QUIT(3), KILL(9), TERM(15)은 같습니다. 정확한 번호는 kill -l이나 /usr/include/sys/signal.h로 확인합니다.