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"
<[email protected]>) 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
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,
[Index of Archives]
[Kernel Newbies]
[Netfilter]
[Bugtraq]
[Photo]
[Stuff]
[Gimp]
[Yosemite News]
[MIPS Linux]
[ARM Linux]
[Linux Security]
[Linux RAID]
[Video 4 Linux]
[Linux for the blind]
[Linux Resources]