Force a core to dump from an active, normally running program on FreeBSD

Viewed 56688

I'm writing error handling code for a server on FreeBSD. For extremely serious errors I want to avoid data corruption by immediately terminating. That's easy, exit(3). Before I exit, I output my relevant variables that led me there. However, ideally, this termination would be accompanied by a .core so that I could fully investigate what got me to this catastrophic (and likely hard to reproduce) state.

How can I force this to happen?

6 Answers

On sles12.. Below code worked for me :

kill -11

The previous suggestions did not do anything.

You could also try kill -BUS <pid> which worked for me (though on ubuntu 20.04)

I had no luck with kill -QUIT in a particular case. What worked for me is:

gdb --pid <process_id> -ex "set confirm off" -ex generate-core-file -ex q
Related