Skip to content

Commit

Permalink
fix arbitrary pid for unix
Browse files Browse the repository at this point in the history
  • Loading branch information
wagyourtail committed Aug 20, 2024
1 parent 0d9386f commit 64f0b18
Showing 1 changed file with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ public interface J_L_ProcessHandle extends Comparable<J_L_ProcessHandle> {
RuntimeMXBean bean = ManagementFactory.getRuntimeMXBean();

static Optional<J_L_ProcessHandle> of(long pid) {
if (pid == current().pid()) {
return Optional.of(current());
if (UnixProcessHandle.isUnix()) {
return Optional.of(new UnixProcessHandle(pid));
}
throw new UnsupportedOperationException("Getting arbitrary PID process handles is not supported");
throw MissingStubError.create();
}

static J_L_ProcessHandle current() {
Expand All @@ -49,7 +49,10 @@ public CompletableFuture<J_L_ProcessHandle> onExit() {
}

static Stream<J_L_ProcessHandle> allProcesses() {
return Stream.of(current());
if (UnixProcessHandle.isUnix()) {
return of(0).get().descendants();
}
throw MissingStubError.create();
}

long pid();
Expand Down

0 comments on commit 64f0b18

Please sign in to comment.