On Wed, Mar 03, 2004 at 06:34:06AM -0500, Jeff Trawick wrote:
> This checks for a couple of common conditions which prevent core dumps from
> being taken and writes a NOTICE message to the error log at startup if the
> condition is detected. BTW, the same code works with 1.3 with very minor
> tweaks (remove the apr_status_t parm from ap_log_error IIRC).
I wrote a patch for a essentially the same feature recently: the common
case is where the soft limit is set to zero but the hard limit is not;
so iff CoreDumpDirectory is used, just raise the soft limit to the hard
limit.
--- httpd-2.0.48/server/core.c.corelimit
+++ httpd-2.0.48/server/core.c
@@ -4233,6 +4233,25 @@
ap_set_version(pconf);
ap_setup_make_content_type(pconf);
+
+#ifdef RLIMIT_CORE
+ if (ap_coredumpdir_configured) {
+ struct rlimit lim;
+
+ if (getrlimit(RLIMIT_CORE, &lim) == 0 && lim.rlim_cur == 0) {
+ lim.rlim_cur = lim.rlim_max;
+ if (setrlimit(RLIMIT_CORE, &lim) == 0) {
+ ap_log_error(APLOG_MARK, APLOG_NOTICE, 0, NULL,
+ "core dump file size limit raised to %lu bytes",
+ lim.rlim_cur);
+ } else {
+ ap_log_error(APLOG_MARK, APLOG_NOTICE, errno, NULL,
+ "core dump file size is zero, setrlimit failed");
+ }
+ }
+ }
+#endif
+
return OK;
}