SIGABRT doesn't generate core dumps in MacOS

Viewed 182

In macOS, I find that SIGABRT won't generate core dumps in some cases.

For example, I run a sleep in one terminal:

lianxin.wlx@mbp [01:08:21] [~/test]
-> % sleep 1000

And send a SIGABRT to it in another terminal:

lianxin.wlx@mbp [01:08:59] [~]
-> % ps -ef | grep sleep
  502 47679 20388   0  1:08AM ttys001    0:00.01 sleep 1000
lianxin.wlx@mbp [01:09:03] [~]
-> % kill -6 47679

Then the sleep process is aborted, but no core dump is generated.

lianxin.wlx@mbp [01:08:21] [~/test]
-> % sleep 1000
[1]    47679 abort      sleep 1000
lianxin.wlx@mbp [01:10:35] [~/test]
-> % ls /cores
lianxin.wlx@mbp [01:10:37] [~/test]
-> %

So why? I've tested the same operations in Linux, it did generate a core dump.

I'm sure I've opened the core dump right(ulimit -c unlimited, and /cores's privilege is 777). I wrote a program that will crash with SIGSEGV, and it did generate a core dump in /cores.

1 Answers

If you make a simple program,

main() {
    abort();
}

It will generate a core dump if run with appropriate priv. Also, if you make a:

main() {
    sleep(100);
}

run it in the background and kill -ABRT , it will generate a core dump. But /bin/sleep doesn't, which is a bit odd.

This is assuming you have followed the recipe in man core.

Related