Send attach request even though SigCgt is not set

Yasumasa Suenaga yasuenag at gmail.com
Sat Aug 16 14:44:26 UTC 2025


Hi all,

I'm working on JDK-8365633, then I want to attach to the process via 
jcmd on WSL 1 (to test hybrid CPU on Linux on Windows), however I couldn't.
I want to add a system property like an expert mode to force sending 
signal. What do you think?

I investigated 
src/jdk.attach/linux/classes/sun/tools/attach/VirtualMachineImpl.java , 
then I found following code:

```
         for (var line : Files.readAllLines(procPid.resolve("status"))) {

             if (!line.startsWith("Sig")) continue; // to speed things 
up ... avoids the matcher/RE invocation...

             final var m = SIGNAL_MASK_PATTERN.matcher(line);

             if (!m.matches()) continue;

             var       sigmask = m.group(MASK);
             final var slen    = sigmask.length();

             sigmask = sigmask.substring(slen / 2 , slen); // only 
really interested in the non r/t signals ...

             final var sigquit = (Long.valueOf(sigmask, 16) & SIGQUIT) 
!= 0L;

             switch (m.group(FIELD)) {
                 case "SigBlk": { quitBlk = sigquit; readBlk = true; 
break; }
                 case "SigIgn": { quitIgn = sigquit; readIgn = true; 
break; }
                 case "SigCgt": { quitCgt = sigquit; readCgt = true; 
break; }
             }

             if (readBlk && readIgn && readCgt) break;
         }

         final boolean  okToSendQuit = (!quitIgn && quitCgt); // ignore 
blocked as it may be temporary ...

         if (okToSendQuit) {
             sendQuitTo(pid);
```

This code has been introduced in JDK-8342449.
I agree with not to send signal if it is not accepted by the target, 
however I think it is better to add an option to force the signal to be 
sent.

It seems to be a bug on WSL 1 because it does not seems to cover all of 
Linux signal implementation e.g. 
https://github.com/microsoft/WSL/issues/1880 . So it should be fixed in 
WSL, however it should be available like an expert mode on Attach API 
implementation - I guess it would be added as a system property.

I will file this to JBS and create PR if this proposal is accepted.
I want to hear your comments before that work because I understand it is 
not a bug on Java.
Any comments are welcome.


Thanks,

Yasumasa



More information about the serviceability-dev mailing list