All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] logging coredump event
@ 2005-11-01  7:45 Pengcheng Zou
  0 siblings, 0 replies; only message in thread
From: Pengcheng Zou @ 2005-11-01  7:45 UTC (permalink / raw)
  To: linux-kernel; +Cc: Peter Wang

[-- Attachment #1: Type: text/plain, Size: 592 bytes --]

Hi, 

sometimes daemon dies silently, dont know why, dont know when, dont know where 
the coredump is. attached with a patch (made by "Peter Wang" 
<spwang@corp.netease.com>) to make the sysadm's life a little bit easier, by 
logging the coredump event in syslog (if user allows). 

when enabled (sysctl -w kernel.log_sig_exit=1), some syslog message will be 
generated if a process crash:

Nov  1 15:32:54 localhost kernel: pid 4649 (coredump), uid 0: exited on signal 
11 (core dumped)

and then the sysadm can react promptly.

trivial patch, but IMHO, very useful.

cheers,
  -- Pengcheng

[-- Attachment #2: linux-2.6.14-log-sig-exit.patch --]
[-- Type: text/x-diff, Size: 2002 bytes --]

diff -uprN linux-2.6.13.4.orig/fs/exec.c linux-2.6.13.4/fs/exec.c
--- linux-2.6.13.4.orig/fs/exec.c	2005-10-11 02:54:29.000000000 +0800
+++ linux-2.6.13.4/fs/exec.c	2005-11-01 13:55:50.000000000 +0800
@@ -58,6 +58,7 @@
 
 int core_uses_pid;
 char core_pattern[65] = "core";
+int log_sig_exit=0;
 int suid_dumpable = 0;
 
 EXPORT_SYMBOL(suid_dumpable);
@@ -1523,5 +1524,8 @@ fail_unlock:
 	current->fsuid = fsuid;
 	complete_all(&mm->core_done);
 fail:
+	if(log_sig_exit)
+		printk(KERN_INFO "pid %d (%s), uid %d: exited on signal %u %s\n",
+			current->pid,current->comm,current->uid,signr,retval?"(core dumped)":"");
 	return retval;
 }
diff -uprN linux-2.6.13.4.orig/include/linux/sysctl.h linux-2.6.13.4/include/linux/sysctl.h
--- linux-2.6.13.4.orig/include/linux/sysctl.h	2005-10-11 02:54:29.000000000 +0800
+++ linux-2.6.13.4/include/linux/sysctl.h	2005-11-01 13:56:47.000000000 +0800
@@ -146,6 +146,7 @@ enum
 	KERN_RANDOMIZE=68, /* int: randomize virtual address space */
 	KERN_SETUID_DUMPABLE=69, /* int: behaviour of dumps for setuid core */
 	KERN_SPIN_RETRY=70,	/* int: number of spinlock retries */
+	KERN_LOG_SIG_EXIT=71, /* int: log when task exits because of some signals */
 };
 
 
diff -uprN linux-2.6.13.4.orig/kernel/sysctl.c linux-2.6.13.4/kernel/sysctl.c
--- linux-2.6.13.4.orig/kernel/sysctl.c	2005-10-11 02:54:29.000000000 +0800
+++ linux-2.6.13.4/kernel/sysctl.c	2005-11-01 13:58:21.000000000 +0800
@@ -60,6 +60,7 @@ extern int sysrq_enabled;
 extern int core_uses_pid;
 extern int suid_dumpable;
 extern char core_pattern[];
+extern int log_sig_exit;
 extern int cad_pid;
 extern int pid_max;
 extern int min_free_kbytes;
@@ -298,6 +299,14 @@ static ctl_table kern_table[] = {
 		.strategy	= &sysctl_string,
 	},
 	{
+		.ctl_name = KERN_LOG_SIG_EXIT,
+		.procname = "log_sig_exit",
+		.data  = &log_sig_exit,
+		.maxlen  = sizeof(int),
+		.mode  = 0644,
+		.proc_handler = &proc_dointvec,
+	},
+	{
 		.ctl_name	= KERN_TAINTED,
 		.procname	= "tainted",
 		.data		= &tainted,

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2005-11-01  7:45 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-11-01  7:45 [PATCH] logging coredump event Pengcheng Zou

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.