Re: [PATCH] coredump: add core_pattern specifier for si_code

From: Christian Brauner

Date: Wed Mar 18 2026 - 05:51:00 EST


On Tue, Mar 17, 2026 at 04:00:06PM +0100, Emanuele Rocca wrote:
> The specifiers supported by core_pattern include the option to indicate the
> signal number si_signo by using %s. Other than identifying which signal
> generated a core dump (eg: 11 for SIGSEGV), it is useful to know the reason why
> a certain signal was sent. The signal code si_code (eg: 2 for SEGV_ACCERR)
> provides this information.
>
> Adding the signal code to core_pattern can benefit in particular sysadmins who
> pipe core dumps to user-space programs for later analysis. systemd-coredump(8)
> is a notable example of such programs.
>
> Signed-off-by: Emanuele Rocca <emanuele.rocca@xxxxxxx>
> ---
> Documentation/admin-guide/sysctl/kernel.rst | 1 +
> fs/coredump.c | 5 +++++
> 2 files changed, 6 insertions(+)
>
> diff --git a/Documentation/admin-guide/sysctl/kernel.rst b/Documentation/admin-guide/sysctl/kernel.rst
> index 9aed74e65cf4..20177bd94514 100644
> --- a/Documentation/admin-guide/sysctl/kernel.rst
> +++ b/Documentation/admin-guide/sysctl/kernel.rst
> @@ -170,6 +170,7 @@ core_pattern
> %d dump mode, matches ``PR_SET_DUMPABLE`` and
> ``/proc/sys/fs/suid_dumpable``
> %s signal number
> + %n signal code

Request %F which installs pidfd for the coredumping process into the
coredump helper then use the pidfd info ioctl in you binary with
PIDFD_INFO_EXIT | PIDFD_INFO_COREDUMP and you can retrieve the exit
status including the signal that was sent to the process.