Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SapMachine #1593: Implement a lean alternative for jcmd #1594

Open
wants to merge 5 commits into
base: sapmachine
Choose a base branch
from

Conversation

schmelter-sap
Copy link
Member

@schmelter-sap schmelter-sap commented Jan 29, 2024

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

@SapMachine
Copy link
Member

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

@MBaesken
Copy link
Member

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

@RealCLanger
Copy link
Member

Could you add a smoketest for leanjcmd?

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

@RealCLanger RealCLanger changed the title Create native version of jcmd Implement a lean alternative of jcmd Jan 31, 2024
@RealCLanger RealCLanger changed the title Implement a lean alternative of jcmd Implement a lean alternative for jcmd Jan 31, 2024
@simonis
Copy link
Contributor

simonis commented Jan 31, 2024

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

@RealCLanger
Copy link
Member

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 RealCLanger changed the title Implement a lean alternative for jcmd SapMachine #1593: Implement a lean alternative for jcmd Mar 15, 2024
@SapMachine
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement a lean alternative for jcmd
5 participants