1 hour ago · Tech · 0 comments

This has been bugging me for years: you often run a JVM by a shell script wrapper, then want to jstack it to figure out what it’s doing, but can’t figure out what PID to ask for. Running jps gives remarkably unhelpful output, especially for tools like Leiningen. I wrote a hacky little Ruby script to dig into the process tree of everything matching a given pattern, find any JVMs those processes spawned, and hit the highest numbered one (presumably the last one started) with jstack. This is definitely wrong (PID rollover!) but it’s been surprisingly useful for debugging. $ jstack+ lein test jstack 1044647 (java -classpath /home/aphyr/hegel/test ...) 2026-05-04 10:23:07 Full thread dump OpenJDK 64-Bit Server VM (21.0.10+7-Ubuntu-124.04 mixed mode, emulated-client, sharing): Threads class SMR info: _java_thread_list=0x0000767f88002030, length=12, elements={ 0x000076803801b140, 0x0000768038277460, 0x00007680382789e0, 0x000076803827a2a0, 0x000076803827b8f0, 0x000076803827cea0,…

No comments yet. Log in to reply on the Fediverse. Comments will appear here.