Can OS X dump cores in the working directory instead of /cores? I don't know when it started, but at some point, OS X started dumping cores into a special folder (/cores). This is a pain since they get jumbled together and it's hard to keep track of which core files goes with which execution. Is there an environment variable or special flag I can set to have cores dumped into the working directory (as with other operating systems) instead?
I finally figured this out. It turns out that this is a kernel parameter controlled by sysctl. You can set this on a per shell basis to dump in the current working directory with:

sysctl -w kern.corefile=core.%P


Since I never wanted my core dumps to end up in /cores, but always in the current directory, I added this plist to /Library/LaunchDaemons/:

&lt;!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"&gt;
&lt;plist version="1.0"&gt;
&lt;dict&gt;
    &lt;key&gt;Label&lt;/key&gt;
    &lt;string&gt;sysctl&lt;/string&gt;
    &lt;key&gt;ProgramArguments&lt;/key&gt;
    &lt;array&gt;
        &lt;string&gt;/usr/sbin/sysctl&lt;/string&gt;
        &lt;string&gt;-w&lt;/string&gt;
        &lt;string&gt;kern.corefile=core.%P&lt;/string&gt;
    &lt;/array&gt;
    &lt;key&gt;RunAtLoad&lt;/key&gt;
    &lt;true/&gt;
&lt;/dict&gt;
&lt;/plist&gt;


UPDATE:

Since I wrote this, it looks like the sysctl command changed. I've updated the examples above, but if you were previously using kern.core_pattern, that doesn't work anymore.