Skip to content

Commit

Permalink
Fix getExitStatus race condition (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
ThadHouse authored Dec 12, 2023
1 parent aed7370 commit 7f39cfc
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ buildScan {
}

group = "edu.wpi.first"
version = "2024.0.0"
version = "2024.1.0"

base {
archivesName = "DeployUtils"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,21 @@ public CommandDeployResult execute(String command) {
try {
result = IOGroovyMethods.getText(is);
} finally {
// Wait up to 5 seconds for closed
// isClosed must be true for getExecStatus to be correct.
long start = System.currentTimeMillis();
while(!exec.isClosed()) {
long delta = System.currentTimeMillis() - start;
if (delta > 5000) { // 5 seconds
break;
}
try {
Thread.sleep(100);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
break;
}
}
exec.disconnect();
release(sem);
}
Expand Down

0 comments on commit 7f39cfc

Please sign in to comment.