From: Pengcheng Zou <pczou@redflag-linux.com>
To: linux-kernel@vger.kernel.org
Cc: "Peter Wang" <spwang@corp.netease.com>
Subject: [PATCH] logging coredump event
Date: Tue, 1 Nov 2005 15:45:46 +0800 [thread overview]
Message-ID: <200511011545.46402.pczou@redflag-linux.com> (raw)
[-- 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,
reply other threads:[~2005-11-01 7:45 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200511011545.46402.pczou@redflag-linux.com \
--to=pczou@redflag-linux.com \
--cc=linux-kernel@vger.kernel.org \
--cc=spwang@corp.netease.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.