Skip to content

Commit

Permalink
Sanitize getpid() call if JNA is missing.
Browse files Browse the repository at this point in the history
  • Loading branch information
tresf committed Nov 27, 2020
1 parent 80bd7ae commit 6b1ec5e
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/qz/utils/MacUtilities.java
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,12 @@ public static int getScaleFactor() {
}

public static int getProcessID() {
return CLibrary.INSTANCE.getpid();
try {
return CLibrary.INSTANCE.getpid();
} catch(UnsatisfiedLinkError | NoClassDefFoundError e) {
log.warn("Could not obtain process ID. This usually means JNA isn't working. Returning -1.");
}
return -1;
}

private interface CLibrary extends Library {
Expand Down

0 comments on commit 6b1ec5e

Please sign in to comment.