Java Agent机制
两个线程
- Signal Dispatcher(随jvm启动而启动,处理信号)
- Attach Listener, 这个线程通过Unix Domain Socket跟外部进程通讯(.java_pid
)
On Linux and Solaris, the client creates a file named .attach_pid
and sends a SIGQUIT to the target JVM process. The existence of this file causes the SIGQUIT handler in HotSpot to start the attach listener thread.
- 注意 kill -3 并不会杀死java进程。默认行为是产生thread dump。除非JVM中重新定义了SIGQUIT(-3)的处理handler。产生JVM thread dump
kill -3 pid
两个文件
- .attach_pid
(启动attach listener线程用) - .java_pid
(Unix socket domain)