obtain core dump by aborting the running apps

May 13th, 2007 mysurface Posted in kill, pkill, ulimit | Hits: 70703 | 6 Comments »

To obtain core dump, the line bellow is mandatory.

ulimit -c unlimited

Check out generate coredumps to help developer for debugging for more details of ulimit.

Core dump will be generated automatically if a program crashed due to segmentation fault or some other reason. But core dump will not be generated if an application halt and been terminate by control+c or conventional way of kill or pkill. Therefore, how we are going to investigate the reason of the halt process? There is an option that you can gdb a current running process by specified the GID. But what if you are not the author of the program? You are just a support engineer who wants to escalate the bugs to development team by providing the core file, what can you do?

You can abort the apps and obtain the core dump using kill or pkill. If you check kill man page, you will discover abort signal from the list of signal description with various purpose

...
ABRT       6   core
...

To abort the halt process is easy, with kill you need to specified the GID

kill -6 12345

With pkill, you provide it with the process name.

pkill -6 myapp

[中文翻译]

6 Responses to “obtain core dump by aborting the running apps”

  1. Great post. I’m curious though about the following. One, I thought when you killed a process with ^C that the core dump was written to the current working directory. However, when I do this I do not see the core file. Two, are there any gotchas to using these command on a Windows box running cygwin?

  2. bpw1621:
    1. Control c is to trigger an interrupt signal, same as pkill -2, it will just exit, not core file will be generated.

    2. pkill -6 should have no problem in cygwin.

  3. gcore will generate core without killing the process.

  4. Interesting! Thanks W.G. Will check out the gcore soon.

  5. If i kill the hung process process.
    Then wat steps should i follow to collect the core dump?
    Please revert for this query.

  6. You must also change ulimit -c (check ulimit -a)
    ulimit -c unlimited

Leave a Reply