Skip to content

Commit

Permalink
Filter out jps
Browse files Browse the repository at this point in the history
  • Loading branch information
kevingosse committed Nov 14, 2024
1 parent c2cd3fd commit b36011f
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion lib-injection/build/docker/java/jetty-app/CrashServlet.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ private List<Long> getChildPidsFromProc(long parentPid) {
long ppid = getParentPid(pid);

// If the PPID matches the current process ID, add it to the list
if (ppid == parentPid) {
// Filter out jps because it can be spawned by the java tracer
if (ppid == parentPid && !"jps".equals(getParentPid(ppid))) {
childPids.add(pid);
}
}
Expand Down Expand Up @@ -88,6 +89,16 @@ private long getParentPid(long pid) {
return -1; // Return -1 if we couldn't find the PPid field
}

private String getProcessName(long pid) {
File commFile = new File("/proc/" + pid + "/comm");

try (BufferedReader reader = new BufferedReader(new FileReader(commFile))) {
return reader.readLine();
} catch (IOException e) {
return null;
}
}

private void handleChildPids(HttpServletRequest req, HttpServletResponse resp)
throws IOException {
try {
Expand Down

0 comments on commit b36011f

Please sign in to comment.