Send attach request even though SigCgt is not set
Laurence Cable
larry.cable at oracle.com
Mon Aug 18 15:46:25 UTC 2025
I'm personally extremely disinclined to add an 'expert' property to
'fix' a bug in MSFT WSL's emulation of Linux signals and /proc
semantics.
the code you refer to was added to explicitly avoid the terminal issue
of a jcmd sending SIGQUIT to a JVM unprepared to handle it
since this is is apparently fixed in WSL2 and a bug is filed on WSL1 I
recommend we wait until MSFT fix their code and not
work around it with a mode.
Rgds
- Larry
On 8/16/25 7:44 AM, Yasumasa Suenaga wrote:
> 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