Home > Back-end >  core kernel pattern %e on Linux appends PID
core kernel pattern %e on Linux appends PID

Time:11-24

According to documentation of core the %e in kernel pattern stands for 'The process or thread's comm value'. in addition the core comm value is defined as whatever /proc/[pid]/comm returns. However on my machine (CentOs) despite the kernel pattern is defined as core-%e and comm value returns only process name, PID is still appended to the core name. Why is this discrepancy between the documentation and actual behaviour?

[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

CodePudding user response:

You need to set kernel.core_uses_pid=0 to avoid having the pid appended when %p is missing.

From core(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.

  • Related