SapMachine icon indicating copy to clipboard operation
SapMachine copied to clipboard

SapMachine #1593: Implement a lean alternative for jcmd

Open schmelter-sap opened this issue 1 year ago • 6 comments

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

schmelter-sap avatar Jan 29 '24 12:01 schmelter-sap

Hello @schmelter-sap, this pull request fulfills all formal requirements.

SapMachine avatar Jan 29 '24 12:01 SapMachine

Maybe add a simple '-help' output to the leanjcmd to educate the user about the difference to the 'good' old Java based jcmd?

MBaesken avatar Jan 29 '24 12:01 MBaesken

Could you add a smoketest for leanjcmd?

Also, is this already packaged into JDK/JRE images or would that need additional modifications?

RealCLanger avatar Jan 31 '24 07:01 RealCLanger

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

simonis avatar Jan 31 '24 08:01 simonis

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.

RealCLanger avatar Jan 31 '24 08:01 RealCLanger

Hello @schmelter-sap, this pull request fulfills all formal requirements.

SapMachine avatar Jun 08 '24 20:06 SapMachine