don't dump core dumps

Walter C. Pelissero walter at pelissero.de
Thu Sep 18 16:52:26 PDT 2003


I don't know if this a widespread opinion, but I believe that saving
core files in backup tapes is a waste of time and space, often a big
waste.  Consider that Emacs itself can fill hundred of megs of disk
space with just one core dump, that if you don't bother to debug, it
will likely sit there for months before getting noticed and deleted
straight away.

Forbidding the creation of core files by means such as "sysctl
kern.coredump=0" or "limits -c 0 big-fat-program", is not an option,
because most of the times I do like to have a peek in those core
files.

My idea was to create core files with a NODUMP flag.  A patch like
the following would do the trick:

diff -c /.amd_mnt/daemon/host/usr/warehouse/src/sys/kern/kern_sig.c /usr/home/wcp/tmp/buffer-content-51635BT
*** /.amd_mnt/daemon/host/usr/warehouse/src/sys/kern/kern_sig.c	Mon May 19 16:41:42 2003
--- /usr/home/wcp/tmp/buffer-content-51635BT	Fri Sep 19 01:20:20 2003
***************
*** 119,124 ****
--- 119,128 ----
  SYSCTL_INT(_kern, OID_AUTO, coredump, CTLFLAG_RW,
  	&do_coredump, 0, "Enable/Disable coredumps");
  
+ static int set_coredump_nodump_flag = 1;
+ SYSCTL_INT(_kern, OID_AUTO, coredump, CTLFLAG_RW,
+ 	&set_coredump_nodump_flag, 0, "Enable/Disable setting of NODUMP flag on coredump files");
+ 
  /*
   * Signal properties and actions.
   * The array below categorizes the signals and their default actions
***************
*** 1655,1660 ****
--- 1659,1666 ----
  	VATTR_NULL(&vattr);
  	vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p);
  	vattr.va_size = 0;
+ 	if (set_coredump_nodump_flag)
+ 		vattr.va_flags |= UF_NODUMP;
  	VOP_LEASE(vp, p, cred, LEASE_WRITE);
  	VOP_SETATTR(vp, &vattr, cred, p);
  	p->p_acflag |= ACORE;



Before someone comes up with this: no, excluding files ending in .core
from backups is not an option either.  Dump(8) doesn't have this
option and not all files ending in .core are core dumps (see the CMUCL
image).

Cheers,

-- 
walter pelissero
http://www.pelissero.de


More information about the freebsd-hackers mailing list