SapMachine
SapMachine copied to clipboard
SapMachine #1593: Implement a lean alternative for jcmd
This is aa simple C-base implementation of jcmd. Apart from only taking a pid, it offers the same features, but uses much less memory (and starts vastly faster).
Here is what a jcmd has to do:
- Check if /tmp/.java_pid<pid> exists.
- If not create /tmp/.attach_pid<pid> and send a SIGQUIT to the given pid. This starts the attach thread in the VM, which then creates the /tmp/.java_pid<pid> socket for communication.
- Connect to the /tmp/.java_pid<pid> file socket and write a command consisting of some scaffolding and the parameters to jcmd.
- Write the received output from the file socket to stdout (omitting the result code returned as the first line).
fixes #1593
Hello @schmelter-sap, this pull request fulfills all formal requirements.
Maybe add a simple '-help' output to the leanjcmd to educate the user about the difference to the 'good' old Java based jcmd?
Could you add a smoketest for leanjcmd?
Also, is this already packaged into JDK/JRE images or would that need additional modifications?
Looks like you want to take a look at the jattach utility which does exactly what you want (and a little more :)
https://github.com/jattach/jattach
Looks like you want to take a look at the jattach utility which does exactly what you want (and a little more :)
https://github.com/jattach/jattach
Yep, we are aware of it. However, we'd probably like to have a tool which is always there in SapMachine.
Hello @schmelter-sap, this pull request fulfills all formal requirements.