Linux 什么是“收到信号 15”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16723626/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What is "Signal 15 received"
提问by Jeff
What might cause a C, MPI program using a library called SUNDIALS/CVODE(a numerical ODE solver) running on a Gentoo Linux cluster to give me repeated Signal 15 received.
?
什么可能导致使用名为SUNDIALS/CVODE(数值 ODE 求解器)的库的 C、MPI 程序在 Gentoo Linux 集群上运行,让我重复Signal 15 received.
?
Is that code being issued by MPI, Sundials, Linux, C or who?
该代码是由 MPI、Sundials、Linux、C 还是谁发布的?
Note that I am pretty much a beginner with the following technologies: C, MPI, SUNDIALS/CVODE, and Linux.
请注意,我几乎是以下技术的初学者:C、MPI、SUNDIALS/CVODE 和 Linux。
I can find nothing that seems related by googling the message. I don't even know where to begin to look. (This is one of those questions where "anything helps" is to be taken quite literally.)
通过谷歌搜索消息,我找不到任何似乎相关的内容。我什至不知道从哪里开始看。(这是从字面上理解“任何事情都有帮助”的问题之一。)
(As an aside/afterthought why doesn't Chrome's dictionary recognize the word "googling"?).
(顺便说一句/事后想想为什么 Chrome 的字典不能识别“谷歌搜索”这个词?)。
回答by FatalError
This indicates the linux has delivered a SIGTERM
to your process. This is usually at the request of some other process (via kill()
) but could also be sent by your process to itself (using raise()
). This signal requests an orderly shutdown of your process.
这表明 linux 已经SIGTERM
向您的进程发送了一个。这通常是应某些其他进程的请求(通过kill()
),但也可以由您的进程发送给自身(使用raise()
)。此信号请求有序关闭您的进程。
If you need a quick cheatsheet of signal numbers, open a bash shell and:
如果您需要信号编号的快速备忘单,请打开 bash shell 并:
$ kill -l
1) SIGHUP 2) SIGINT 3) SIGQUIT 4) SIGILL
5) SIGTRAP 6) SIGABRT 7) SIGBUS 8) SIGFPE
9) SIGKILL 10) SIGUSR1 11) SIGSEGV 12) SIGUSR2
13) SIGPIPE 14) SIGALRM 15) SIGTERM 16) SIGSTKFLT
17) SIGCHLD 18) SIGCONT 19) SIGSTOP 20) SIGTSTP
21) SIGTTIN 22) SIGTTOU 23) SIGURG 24) SIGXCPU
25) SIGXFSZ 26) SIGVTALRM 27) SIGPROF 28) SIGWINCH
29) SIGIO 30) SIGPWR 31) SIGSYS 34) SIGRTMIN
35) SIGRTMIN+1 36) SIGRTMIN+2 37) SIGRTMIN+3 38) SIGRTMIN+4
39) SIGRTMIN+5 40) SIGRTMIN+6 41) SIGRTMIN+7 42) SIGRTMIN+8
43) SIGRTMIN+9 44) SIGRTMIN+10 45) SIGRTMIN+11 46) SIGRTMIN+12
47) SIGRTMIN+13 48) SIGRTMIN+14 49) SIGRTMIN+15 50) SIGRTMAX-14
51) SIGRTMAX-13 52) SIGRTMAX-12 53) SIGRTMAX-11 54) SIGRTMAX-10
55) SIGRTMAX-9 56) SIGRTMAX-8 57) SIGRTMAX-7 58) SIGRTMAX-6
59) SIGRTMAX-5 60) SIGRTMAX-4 61) SIGRTMAX-3 62) SIGRTMAX-2
63) SIGRTMAX-1 64) SIGRTMAX
You can determine the sender by using an appropriate signal handler like:
您可以使用适当的信号处理程序来确定发送者,例如:
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
void sigterm_handler(int signal, siginfo_t *info, void *_unused)
{
fprintf(stderr, "Received SIGTERM from process with pid = %u\n",
info->si_pid);
exit(0);
}
int main (void)
{
struct sigaction action = {
.sa_handler = NULL,
.sa_sigaction = sigterm_handler,
.sa_mask = 0,
.sa_flags = SA_SIGINFO,
.sa_restorer = NULL
};
sigaction(SIGTERM, &action, NULL);
sleep(60);
return 0;
}
Notice that the signal handler also includes a call to exit()
. It's also possible for your program to continue to execute by ignoring the signal, but this isn't recommended in general (if it's a user doing it there's a good chance it will be followed by a SIGKILL if your process doesn't exit, and you lost your opportunity to do any cleanup then).
请注意,信号处理程序还包括对 的调用exit()
。您的程序也可以通过忽略信号继续执行,但通常不建议这样做(如果是用户执行此操作,如果您的进程没有退出,则很有可能会出现 SIGKILL,并且你失去了做任何清理的机会)。