Skip to content

Commit

Permalink
JDK-8342449: minor changes in response to previous review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
larry-cable committed Nov 12, 2024
1 parent 2e89bd5 commit 7f43e37
Showing 1 changed file with 9 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -322,9 +322,9 @@ private long getNamespacePid(long pid) throws AttachNotSupportedException, IOExc
private static final String FIELD = "field";
private static final String MASK = "mask";

private static final String SIGNAL_MASK_PATTERN = "(?<" + FIELD + ">Sig\\p{Alpha}{3}):\\s+(?<" + MASK + ">\\p{XDigit}{16}).*";
private static final Pattern SIGNAL_MASK_PATTERN = Pattern.compile("(?<" + FIELD + ">Sig\\p{Alpha}{3}):\\s+(?<" + MASK + ">\\p{XDigit}{16}).*");

private static final long SIGQUIT = 1L << 2;
private static final long SIGQUIT = 0b100; // mask bit for SIGQUIT

private static boolean checkCatchesAndSendQuitTo(int pid, boolean throwIfNotReady) throws AttachNotSupportedException, IOException {
var quitIgn = false;
Expand All @@ -333,8 +333,6 @@ private static boolean checkCatchesAndSendQuitTo(int pid, boolean throwIfNotRead

final var procPid = PROC.resolve(Integer.toString(pid));

final var p = Pattern.compile(SIGNAL_MASK_PATTERN);

var readBlk = false;
var readIgn = false;
var readCgt = false;
Expand All @@ -346,21 +344,21 @@ private static boolean checkCatchesAndSendQuitTo(int pid, boolean throwIfNotRead

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

final var m = p.matcher(line);
final var m = SIGNAL_MASK_PATTERN.matcher(line);

if (!m.matches()) continue;

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

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

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

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

if (readBlk && readIgn && readCgt) break;
Expand Down

0 comments on commit 7f43e37

Please sign in to comment.