Rework and document OS class

This commit is contained in:
DaCool
2023-11-12 13:57:18 +00:00
committed by harlekin
parent 1ef0b2f4b7
commit d2b9985be8
5 changed files with 89 additions and 29 deletions

View File

@@ -46,7 +46,7 @@ public class Mac extends OS {
@Override public Process exec(List<String> command, Map<String, String> env) throws IOException {
List<String> actual_command = command;
if (checkNiceAvailability()) {
if (isNiceAvailable()) {
// launch the process in lowest priority
if (env != null) {
actual_command.add(0, env.get("PRIORITY"));
@@ -78,7 +78,7 @@ public class Mac extends OS {
return "/usr/local/cuda/lib/libcuda.dylib";
}
@Override public boolean getSupportHighPriority() {
@Override public boolean isHighPrioritySupported() {
try {
ProcessBuilder builder = new ProcessBuilder();
builder.command("bash", "-c", ID_COMMAND_INVOCATION);
@@ -92,7 +92,7 @@ public class Mac extends OS {
if ((userLevel = reader.readLine()) != null) {
// Root user in *ix systems -independently of the alias used to login- has a id value of 0. On top of being a user with root capabilities,
// to support changing the priority the nice tool must be accessible from the current user
return (userLevel.equals("0")) & checkNiceAvailability();
return (userLevel.equals("0")) & isNiceAvailable();
}
}
catch (IOException e) {
@@ -102,7 +102,7 @@ public class Mac extends OS {
return false;
}
@Override public boolean checkNiceAvailability() {
@Override public boolean isNiceAvailable() {
ProcessBuilder builder = new ProcessBuilder();
builder.command(NICE_BINARY_PATH);
builder.redirectErrorStream(true);