Adds signal number format to kern.corefile

Add format capability to core file names to include signal
that generated the core. This can help various validation workflows
where all cores should not be considered equally (SIGQUIT is often
intentional and not an error unlike SIGSEGV or SIGBUS)

Submitted by:	David Leimbach (leimy2k@gmail.com)
Reviewed by:	markj
MFC after:	1 week
Relnotes:	sysctl kern.corefile can now include the signal number
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D20970
This commit is contained in:
Eric van Gyzen 2019-07-16 15:51:09 +00:00
parent 7af2abed6a
commit 9d3ecb7e62
2 changed files with 7 additions and 2 deletions

View File

@ -82,6 +82,8 @@ generated by a particular process.
process name.
.It Em \&%P
processes PID.
.It Em \&%S
signal during core.
.It Em \&%U
process UID.
.El

View File

@ -3433,7 +3433,7 @@ corefile_open_last(struct thread *td, char *name, int indexpos,
*/
static int
corefile_open(const char *comm, uid_t uid, pid_t pid, struct thread *td,
int compress, struct vnode **vpp, char **namep)
int compress, int signum, struct vnode **vpp, char **namep)
{
struct sbuf sb;
struct nameidata nd;
@ -3482,6 +3482,9 @@ corefile_open(const char *comm, uid_t uid, pid_t pid, struct thread *td,
case 'P': /* process id */
sbuf_printf(&sb, "%u", pid);
break;
case 'S': /* signal number */
sbuf_printf(&sb, "%i", signum);
break;
case 'U': /* user id */
sbuf_printf(&sb, "%u", uid);
break;
@ -3599,7 +3602,7 @@ coredump(struct thread *td)
PROC_UNLOCK(p);
error = corefile_open(p->p_comm, cred->cr_uid, p->p_pid, td,
compress_user_cores, &vp, &name);
compress_user_cores, p->p_sig, &vp, &name);
if (error != 0)
return (error);