aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHÃ¥kon Hallingstad <hakon@verizonmedia.com>2020-09-14 20:52:27 +0200
committerGitHub <noreply@github.com>2020-09-14 20:52:27 +0200
commit5fdc4f08fd6bf8dea298bea1cb64ef4dd9458db7 (patch)
tree2c330851b5b3263abe8d2de1e6408339cd61737d
parentea22ec7cb6e35cf591d08ffe898388a7f08593cc (diff)
parent1dc8fa3c988576ee2ad8d78a83df8afa0f5fa736 (diff)
Merge pull request #14402 from vespa-engine/hakonhall/support-not-waiting-for-termination-of-command
Support not waiting for termination of command
-rw-r--r--node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/task/util/process/CommandLine.java14
1 files changed, 14 insertions, 0 deletions
diff --git a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/task/util/process/CommandLine.java b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/task/util/process/CommandLine.java
index d86c8745ceb..e00c1dabf0f 100644
--- a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/task/util/process/CommandLine.java
+++ b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/task/util/process/CommandLine.java
@@ -59,6 +59,7 @@ public class CommandLine {
private Duration sigTermGracePeriod = DEFAULT_SIGTERM_GRACE_PERIOD;
private Duration sigKillGracePeriod = DEFAULT_SIGKILL_GRACE_PERIOD;
private Predicate<Integer> successfulExitCodePredicate = code -> code == 0;
+ private boolean waitForTermination = true;
public CommandLine(TaskContext taskContext, ProcessFactory processFactory) {
this.taskContext = taskContext;
@@ -242,6 +243,15 @@ public class CommandLine {
return this;
}
+ /**
+ * WARNING: This will leave the child as a zombie process until this process dies.
+ * I.e. only use this just before or a limited number of times per host admin restart.
+ */
+ public CommandLine doNotWaitForTermination() {
+ this.waitForTermination = false;
+ return this;
+ }
+
public List<String> getArguments() { return Collections.unmodifiableList(arguments); }
// Accessor fields necessary for classes in this package. Could be public if necessary.
@@ -256,6 +266,10 @@ public class CommandLine {
private CommandResult doExecute() {
try (ChildProcess2 child = processFactory.spawn(this)) {
+ if (!waitForTermination) {
+ return new CommandResult(this, 0, "");
+ }
+
child.waitForTermination();
int exitCode = child.exitCode();
if (!successfulExitCodePredicate.test(exitCode)) {