Can OS X dump cores in the working directory instead of /cores?
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/
:
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>sysctl</string>
<key>ProgramArguments</key>
<array>
<string>/usr/sbin/sysctl</string>
<string>-w</string>
<string>kern.corefile=core.%P</string>
</array>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>
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.