Linux 上的核心内核模式 %e 附加 PID

core kernel pattern %e on Linux appends PID

根据 core the %e in kernel pattern stands for 'The process or thread's comm value'. in addition the core comm value is defined 的文档,无论是 /proc/[pid]/comm returns。然而在我的机器(CentOs)上,尽管内核模式被定义为 core-%e 和 comm 值 returns 只有进程名称,PID 仍然附加到核心名称。为什么文档和实际行为之间存在这种差异?

[root@mde-segment-bouretskey dump]# cat /proc/sys/kernel/core_pattern
/tmp/dump/core-%e
[root@mde-segment-bouretskey dump]# ls /tmp/dump/core-*
/tmp/dump/core-a.out.42098  /tmp/dump/core-a.out.43097
[root@mde-segment-bouretskey dump]#

[root@mde-segment-bouretskey crashtest]# cat /proc/45301/comm
a.out

您需要设置 kernel.core_uses_pid=0 以避免在缺少 %p 时附加 pid。

来自核心(5):

For backward compatibility, if /proc/sys/kernel/core_pattern does not include %p and /proc/sys/kernel/core_uses_pid (see below) is nonzero, then .PID will be appended to the core filename.