Last week encountered a process hang on Linux; well the need arises to take the dump of the process. You can generate the dumps of a running process on Linux in two ways.
1. gcore - The gcore utility creates a core image of the specified process.
gcore [-s] pid
-s Stop the process while gathering the core image, and resume it when done. This guarantees that the resulting core dump will be in a consistent state. The process is resumed even if it was already stopped.
$ gcore -s 547
...
...
Saved corefile core.547
2. Using gdb
First attach gdb to the running process.
$ gdb - 547 # note the - has spaces on both sides.
Or
You can use gdb's attach
$ gdb
(gdb) attach 547
Once you are attached to the running process, you can take the dump using generate-core-file(gcore) command.
(gdb) generate-core-file
Saved corefile core.547
No comments:
Post a Comment