From 1bdbdbb3983923b1adcf1bbcf2d0b3c5a2bc8b4c Mon Sep 17 00:00:00 2001 From: kohsuke Date: Mon, 6 Jul 2009 22:16:56 +0000 Subject: [PATCH] added the simplest kill method git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@19440 71c3de6d-444a-0410-be80-ed276b4c234a --- core/pom.xml | 2 +- .../main/java/hudson/util/ProcessTree.java | 19 +++++++++++++------ 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/core/pom.xml b/core/pom.xml index 8ee70efb49..28bbb7044b 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -596,7 +596,7 @@ THE SOFTWARE. org.jvnet.winp winp - 1.10 + 1.11 org.jvnet.hudson diff --git a/core/src/main/java/hudson/util/ProcessTree.java b/core/src/main/java/hudson/util/ProcessTree.java index 6f4bd2eb23..bc14679cd9 100644 --- a/core/src/main/java/hudson/util/ProcessTree.java +++ b/core/src/main/java/hudson/util/ProcessTree.java @@ -77,7 +77,7 @@ public abstract class ProcessTree implements Iterable { /** * To be filled in the constructor of the derived type. */ - private final Map processes = new HashMap(); + protected final Map processes = new HashMap(); // instantiation only allowed for subtypes in this class private ProcessTree() {} @@ -158,11 +158,10 @@ public abstract class ProcessTree implements Iterable { return r; } - // TODO: pending new Winp -// /** -// * Kills this process. -// */ -// public abstract void kill(); + /** + * Kills this process. + */ + public abstract void kill(); /** * Kills this process and all the descendants. @@ -266,6 +265,10 @@ public abstract class ProcessTree implements Iterable { proc.destroy(); } + public void kill() { + proc.destroy(); + } + public List getArguments() { return Collections.emptyList(); } @@ -302,6 +305,10 @@ public abstract class ProcessTree implements Iterable { p.killRecursively(); } + public void kill() { + p.kill(); + } + @Override public synchronized List getArguments() { if(args==null) args = Arrays.asList(QuotedStringTokenizer.tokenize(p.getCommandLine())); -- GitLab