htop杀死信号有哪些不同?


9

我最近开始使用htop,并且一直需要终止进程,但是当按下F9该进程时,它一直在为我提供此选项列表,我只是选择了默认情况下选择的一个,但我不知道该怎么做确实可以,尽管似乎可行:

htop信号选项

所以,实际上我的问题是,这些不同的选择是什么?最适合用来终止进程的选择是什么?


Answers:


11

第一次尝试

SIGTERM      15       Term    Termination signal

如果这不起作用

SIGKILL       9       Term    Kill signal

man 7 signal

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.

Next the signals not in the POSIX.1-1990 standard but described in
SUSv2 and POSIX.1-2001.

Signal       Value     Action   Comment
────────────────────────────────────────────────────────────────────
SIGBUS      10,7,10     Core    Bus error (bad memory access)
SIGPOLL                 Term    Pollable event (Sys V).
                                Synonym for SIGIO
SIGPROF     27,27,29    Term    Profiling timer expired
SIGSYS      12,31,12    Core    Bad argument to routine (SVr4)
SIGTRAP        5        Core    Trace/breakpoint trap
SIGURG      16,23,21    Ign     Urgent condition on socket (4.2BSD)
SIGVTALRM   26,26,28    Term    Virtual alarm clock (4.2BSD)
SIGXCPU     24,24,30    Core    CPU time limit exceeded (4.2BSD)
SIGXFSZ     25,25,31    Core    File size limit exceeded (4.2BSD)

最好使用SIGINT,类似于按Ctrl + C并仍然让程序有序完成。我在使用Gurobi终止优化运行时使用它:它立即停止程序,但找到的最佳解决方案仍写入文件中。
CGFoX

5

这些通常是过程信号,而不仅仅是与之相关的htop,您可以使用以下命令列出所有信号

kill -l

例如来源

-1或-HUP-此参数使kill将“挂起”信号发送到进程。这可能源自调制解调器/拨号时代。必须对流程进行编程,以实际侦听此流程并对其进行处理。大多数守护程序被编程为在接收到这样的信号时重新读取其配置。无论如何; 这很可能是最安全的信号,它不应阻塞任何信号。

-2或-SIGINT-这与启动某些程序并在执行过程中按CTRL + C相同。大多数程序将停止,您可能会丢失数据。

-9或-KILL-内核将不通知进程而放弃该进程。诸如此类的不洁杀死可能会导致数据丢失。这是可用的“最难”,“最粗糙”和最不安全的终止信号,仅应用于阻止似乎无法阻止的操作。

-15或-TERM-告诉进程停止正在执行的操作,然后结束自身。当您不指定任何信号时,将使用此信号。它应该相当安全,但是最好以“ -1”或“ -HUP”开头。

signal.h文件列表:

+--------------------+------------------+
 *  |  POSIX signal      |  default action  |
 *  +--------------------+------------------+
 *  |  SIGHUP            |  terminate   |
 *  |  SIGINT            |  terminate   |
 *  |  SIGQUIT           |  coredump    |
 *  |  SIGILL            |  coredump    |
 *  |  SIGTRAP           |  coredump    |
 *  |  SIGABRT/SIGIOT    |  coredump    |
 *  |  SIGBUS            |  coredump    |
 *  |  SIGFPE            |  coredump    |
 *  |  SIGKILL           |  terminate(+)    |
 *  |  SIGUSR1           |  terminate   |
 *  |  SIGSEGV           |  coredump    |
 *  |  SIGUSR2           |  terminate   |
 *  |  SIGPIPE           |  terminate   |
 *  |  SIGALRM           |  terminate   |
 *  |  SIGTERM           |  terminate   |
 *  |  SIGCHLD           |  ignore      |
 *  |  SIGCONT           |  ignore(*)   |
 *  |  SIGSTOP           |  stop(*)(+)      |
 *  |  SIGTSTP           |  stop(*)     |
 *  |  SIGTTIN           |  stop(*)     |
 *  |  SIGTTOU           |  stop(*)     |
 *  |  SIGURG            |  ignore      |
 *  |  SIGXCPU           |  coredump    |
 *  |  SIGXFSZ           |  coredump    |
 *  |  SIGVTALRM         |  terminate   |
 *  |  SIGPROF           |  terminate   |
 *  |  SIGPOLL/SIGIO     |  terminate   |
 *  |  SIGSYS/SIGUNUSED  |  coredump    |
 *  |  SIGSTKFLT         |  terminate   |
 *  |  SIGWINCH          |  ignore      |
 *  |  SIGPWR            |  terminate   |
 *  |  SIGRTMIN-SIGRTMAX |  terminate       |
 *  +--------------------+------------------+
 *  |  non-POSIX signal  |  default action  |
 *  +--------------------+------------------+
 *  |  SIGEMT            |  coredump    |
 *  +--------------------+------------------+

进一步阅读:


从列表中,您大多数人看起来都是一样的,那么看起来做同样事情的人之间有什么区别呢?

1
每个陷阱信号以其方式不同,但结果大多数都相同。看看参考资料,再加上手册页以获取完整的文档,实际上您可以为每个信号写一本书!
Maythux
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.