命令KILL可以发送所有信号吗?
Command KILL can send all signals?
我想知道是否可以使用 Kill 命令在进程上发送所有信号。
我看过Kill和Signal的手册(第7节),但我不知道Linux中的信号是否都可以与Kill一起使用。
谢谢
是的,你可以。有很多方法。最简单的方法是:
kill -signalnumber pid1 pid2 ...
是的,可以。
你可以这样使用它:
kill [options] <pid> [...]
示例:
kill -USR1 6127
这将发送 USR1 信号以处理 pid 6127
否则信号编号:
kill -9 6127
所有这些都在 kill 手册上有详细说明,你可以在终端上输入 man kill
看到它,输出将是这样的:
NAME
kill - send a signal to a process
SYNOPSIS
kill [options] [...]
DESCRIPTION
The default signal for kill is TERM. Use -l or -L to list available signals. Particularly useful signals include HUP, INT,
KILL, STOP, CONT, and 0. Alternate signals may be specified in three
ways:
-9, -SIGKILL or -KILL. Negative PID values may be used to choose whole process groups; see the PGID column in ps command output.
A PID of -1 is special; it indicates all processes except the kill
process itself and init.
您可以键入 kill -l
查看信号的简短列表,或者您可以使用 man 7 signal
查看信号 (7) 手册以查看完整的信号列表和描述:
Standard signals
Linux supports the standard signals listed below. Several signal numbers are architecture-dependent, as indicated in the "Value"
column. (Where three values are given, the first one is usually valid
for alpha and sparc, the middle one for x86, arm, and most other architectures, and the last one for mips. (Values for parisc
are not shown; see the Linux kernel source for signal numbering on
that
architecture.) A - denotes that a signal is absent on the corresponding architecture.)
First the signals described in the original POSIX.1-1990 standard.
Signal Value Action Comment
──────────────────────────────────────────────────────────────────────
SIGHUP 1 Term Hangup detected on controlling terminal
or death of controlling process
SIGINT 2 Term Interrupt from keyboard
SIGQUIT 3 Core Quit from keyboard
SIGILL 4 Core Illegal Instruction
SIGABRT 6 Core Abort signal from abort(3)
SIGFPE 8 Core Floating point exception
SIGKILL 9 Term Kill signal
SIGSEGV 11 Core Invalid memory reference
SIGPIPE 13 Term Broken pipe: write to pipe with no
readers
SIGALRM 14 Term Timer signal from alarm(2)
SIGTERM 15 Term Termination signal
SIGUSR1 30,10,16 Term User-defined signal 1
SIGUSR2 31,12,17 Term User-defined signal 2
SIGCHLD 20,17,18 Ign Child stopped or terminated
SIGCONT 19,18,25 Cont Continue if stopped
SIGSTOP 17,19,23 Stop Stop process
SIGTSTP 18,20,24 Stop Stop typed at terminal
SIGTTIN 21,21,26 Stop Terminal input for background process
SIGTTOU 22,22,27 Stop Terminal output for background process
The signals SIGKILL and SIGSTOP cannot be caught, blocked, or ignored.
还有很多关于信号的更多信息。 ;)
我们可以通过with
发送信号进行处理
kill -signal pid1 [pid2 ... pidn]
杀戮-9 1379 3001
或者您可以按名称向一组进程发送信号
killall -s 信号进程名
killall -s SIGTERM firefox
但是,进程如何使用信号取决于此信号是否在同一用户中 space 以及信号是否可以被进程捕获。
我们有很多可能的信号,手动捕获或忽略等,必须有人参与。
但其他人,取决于您如何编程以响应信号。
我想知道是否可以使用 Kill 命令在进程上发送所有信号。
我看过Kill和Signal的手册(第7节),但我不知道Linux中的信号是否都可以与Kill一起使用。
谢谢
是的,你可以。有很多方法。最简单的方法是:
kill -signalnumber pid1 pid2 ...
是的,可以。
你可以这样使用它:
kill [options] <pid> [...]
示例:
kill -USR1 6127
这将发送 USR1 信号以处理 pid 6127
否则信号编号:
kill -9 6127
所有这些都在 kill 手册上有详细说明,你可以在终端上输入 man kill
看到它,输出将是这样的:
NAME kill - send a signal to a process
SYNOPSIS kill [options] [...]
DESCRIPTION The default signal for kill is TERM. Use -l or -L to list available signals. Particularly useful signals include HUP, INT, KILL, STOP, CONT, and 0. Alternate signals may be specified in three ways: -9, -SIGKILL or -KILL. Negative PID values may be used to choose whole process groups; see the PGID column in ps command output. A PID of -1 is special; it indicates all processes except the kill process itself and init.
您可以键入 kill -l
查看信号的简短列表,或者您可以使用 man 7 signal
查看信号 (7) 手册以查看完整的信号列表和描述:
Standard signals Linux supports the standard signals listed below. Several signal numbers are architecture-dependent, as indicated in the "Value" column. (Where three values are given, the first one is usually valid for alpha and sparc, the middle one for x86, arm, and most other architectures, and the last one for mips. (Values for parisc are not shown; see the Linux kernel source for signal numbering on that architecture.) A - denotes that a signal is absent on the corresponding architecture.)
First the signals described in the original POSIX.1-1990 standard. Signal Value Action Comment ────────────────────────────────────────────────────────────────────── SIGHUP 1 Term Hangup detected on controlling terminal or death of controlling process SIGINT 2 Term Interrupt from keyboard SIGQUIT 3 Core Quit from keyboard SIGILL 4 Core Illegal Instruction SIGABRT 6 Core Abort signal from abort(3) SIGFPE 8 Core Floating point exception SIGKILL 9 Term Kill signal SIGSEGV 11 Core Invalid memory reference SIGPIPE 13 Term Broken pipe: write to pipe with no readers SIGALRM 14 Term Timer signal from alarm(2) SIGTERM 15 Term Termination signal SIGUSR1 30,10,16 Term User-defined signal 1 SIGUSR2 31,12,17 Term User-defined signal 2 SIGCHLD 20,17,18 Ign Child stopped or terminated SIGCONT 19,18,25 Cont Continue if stopped SIGSTOP 17,19,23 Stop Stop process SIGTSTP 18,20,24 Stop Stop typed at terminal SIGTTIN 21,21,26 Stop Terminal input for background process SIGTTOU 22,22,27 Stop Terminal output for background process The signals SIGKILL and SIGSTOP cannot be caught, blocked, or ignored.
还有很多关于信号的更多信息。 ;)
我们可以通过with
发送信号进行处理kill -signal pid1 [pid2 ... pidn]
杀戮-9 1379 3001
或者您可以按名称向一组进程发送信号
killall -s 信号进程名
killall -s SIGTERM firefox
但是,进程如何使用信号取决于此信号是否在同一用户中 space 以及信号是否可以被进程捕获。
我们有很多可能的信号,手动捕获或忽略等,必须有人参与。
但其他人,取决于您如何编程以响应信号。