get stack trace of a detached jvm
To get the stack trace of a running java process the usual way is to hit Ctrl-\ on the terminal.
The jvm then print out its current state and threads'stacks.
This become a problem when the Java program is detached from the terminal as all the outputs are then discarded.
Starting to JDK5, the jstack tool is here to help or when you own the code running into the jvm and/or you can change
the way the jvm is launched an easy way is to redirect the standard streams to log file and then to send the
QUIT signal to the jvm pid.
I had to deal with another situation in which jvm was running on jdk 4 and It was not possible to change anything about it.
The trick I then used was to write a small script which catch all the write calls on stderr on the jvm .
The script use strace(1) on Linux and truss(1) on Solaris to
catch what is passed to write calls on
file descriptor 1.
This script is available here :
catch_vm_dump.tcl

Posted at 07:40PM août 08, 2007 by ejannett in Unix | Comments[0]
Today's Page Hits: 17