Skip to content

Commit

Permalink
wait for exit of sysctl (#4754)
Browse files Browse the repository at this point in the history
Signed-off-by: Paul Harris <paul.harris@consensys.net>
Co-authored-by: Adrian Sutton <adrian.sutton@consensys.net>
  • Loading branch information
rolfyone and ajsutton authored Dec 7, 2021
1 parent 0bfcae9 commit 7dd3378
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions bls/src/main/java/tech/pegasys/teku/bls/impl/blst/MacCpuInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

import java.io.IOException;
import java.nio.charset.Charset;
import java.util.concurrent.TimeUnit;
import org.apache.commons.io.IOUtils;

public class MacCpuInfo {
Expand All @@ -29,6 +30,15 @@ private static boolean macHasCpuFeature(final String cpuFeature) throws IOExcept
.redirectErrorStream(true)
.start();
final String output = IOUtils.toString(process.getInputStream(), Charset.defaultCharset());

try {
if (!process.waitFor(5, TimeUnit.SECONDS)) {
throw new IllegalStateException("sysctl took too long to exit.");
}
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new IllegalStateException("Interrupted while waiting for sysctl to exit", e);
}
return process.exitValue() == 0 && output != null && output.trim().equals("1");
}
}

0 comments on commit 7dd3378

Please sign in to comment.