Sending a SIGBREAK signal to a Java process to do a thread dump in Windows
In Linux / Unix if you want a Java process to do a thread dump, you can do a kill -3 <pid>.
In Windows, doing the equivalent requires sending a Ctrl+Break to the input console which results in a SIGBREAK being sent to the process. But what if you do not have an input console? A process started with javaw.exe like what Eclipse does has no input console where you can type in the Ctrl+Break.
So, if you have a running java process without an input console, how do you make it do a thread dump?
The answer is simple – use a utility called SendSignal. Very cleverly written stuff. The author’s description of how he wrote that and some other utilities as part of his Windows programming interests is a nice read.
So, download SendSignal and keep it handy as part of your developer arsenal.
SendSignal.exe <pid> will send a ctrl+break to the process. This will cause a Java process to do a stack dump to stdout.
There are other ways too. Those are for another post.
Tags: Debugging, Java