@bmike gave me most of what I needed. A few additional clues and limitations.
Emacs is an app that lives in /Applications/Emacs.app and it has lots of stuff within that directory. I finally took it one step at a time. I created a dumpme
app:
#include <unistd.h>
#include <signal.h>
int main(int argc, char *argv[])
{
pid_t pid = getpid();
kill(pid, SIGBUS);
}
and I did the codesign
as suggested and I got a core file. Note that before the code side, I would get
zsh: bus error ./dumpme
and after the codesign
I would get:
zsh: bus error (core dumped) ./dumpme
A preliminary step in building the Emacs
app is temacs
which is an executable without an initial state. I codesign
ed it and it produced a core too when started from the Terminal
prompt. Then I did the codesign
for /Applications/Emacs.app/Contents/MacOS/Emacs
and I got this nastygram:
codesign -s - -f --entitlements tmp.entitlements /Applications/Emacs.app/Contents/MacOS/Emacs
/Applications/Emacs.app/Contents/MacOS/Emacs: replacing existing signature
/Applications/Emacs.app/Contents/MacOS/Emacs: code object is not signed at all
In subcomponent: /Applications/Emacs.app/Contents/MacOS/Emacs.pdmp
A search found this answer so I backed up and I did sudo codesign -s - -f --deep --entitlements tmp.entitlements /Applications/Emacs.app
-- (Note the addition of --deep
). Also, without the sudo
I got permission problems.
If I start Emacs from the Finder
or via open /Applications/Emacs.app
and kill it, I do not get a core file. But if I start it from my Terminal
prompt I do. e.g.
% /Applications/Emacs.app/Contents/MacOS/Emacs
I suspect there is a fix when starting from Finder
as well. I'm assuming it has something to do with the ulimit -c unlimited
that is suggested / required.
Update:
Take Finder out of the equation. Get the app to set the limit itself. i.e.
#include <unistd.h>
#include <signal.h>
#include <sys/resource.h>
#include <stdio.h>
int main(int argc, char *argv[])
{
pid_t pid = getpid();
struct rlimit l;
int ret = getrlimit(RLIMIT_CORE, &l);
printf("getrlimit returned %d\n", ret);
printf("rlim_cur = %llu\n", l.rlim_cur);
printf("rlim_max = %llu\n", l.rlim_max);
l.rlim_cur = l.rlim_max;
printf("setrlimit returned %d\n", setrlimit(RLIMIT_CORE, &l));
printf("Time to kill myself\n");
kill(pid, SIGBUS);
}
A modified Emacs.app even when started from Finder now produces a core dump.
ulimit -c unlimited
on the Finder isn't obvious. So I'm going to see if I can get Emacs to core dump when launched from a Terminal and get that much working and then try to solve the ulimit problem of finder. Thank you for your help