From dce4dfacfb391daf349cdfb22beebbc04434b661 Mon Sep 17 00:00:00 2001 From: kohsuke Date: Thu, 10 Jun 2010 04:11:48 +0000 Subject: [PATCH] Merged revisions 31908-31909 via svnmerge from https://svn.dev.java.net/svn/hudson/branches/rc ........ r31908 | kohsuke | 2010-06-09 20:47:06 -0700 (Wed, 09 Jun 2010) | 1 line additional compilation problem ........ r31909 | kohsuke | 2010-06-09 21:08:13 -0700 (Wed, 09 Jun 2010) | 1 line fixing compilation problems ........ git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@31910 71c3de6d-444a-0410-be80-ed276b4c234a --- core/src/main/java/hudson/Launcher.java | 18 +++++++++++++++--- .../java/hudson/slaves/CommandLauncher.java | 12 ++++++++++-- .../java/hudson/util/ProcessTreeKiller.java | 6 +++--- 3 files changed, 28 insertions(+), 8 deletions(-) diff --git a/core/src/main/java/hudson/Launcher.java b/core/src/main/java/hudson/Launcher.java index 0fcdaffe1b..cdc5082f78 100644 --- a/core/src/main/java/hudson/Launcher.java +++ b/core/src/main/java/hudson/Launcher.java @@ -49,6 +49,8 @@ import java.util.Arrays; import java.util.Map; import java.util.List; import java.util.ArrayList; +import java.util.logging.Level; +import java.util.logging.Logger; import static org.apache.commons.io.output.NullOutputStream.NULL_OUTPUT_STREAM; @@ -651,7 +653,7 @@ public abstract class Launcher { } @Override - public void kill(Map modelEnvVars) { + public void kill(Map modelEnvVars) throws InterruptedException { ProcessTree.get().killAll(modelEnvVars); } @@ -678,7 +680,11 @@ public abstract class Launcher { protected synchronized void terminate(IOException e) { super.terminate(e); ProcessTree pt = ProcessTree.get(); - pt.killAll(proc,cookie); + try { + pt.killAll(proc,cookie); + } catch (InterruptedException x) { + LOGGER.log(Level.INFO, "Interrupted", x); + } } @Override @@ -746,7 +752,11 @@ public abstract class Launcher { } public Void call() throws RuntimeException { - ProcessTree.get().killAll(modelEnvVars); + try { + ProcessTree.get().killAll(modelEnvVars); + } catch (InterruptedException e) { + // we are asked to terminate early by the caller, so no need to do anything + } return null; } @@ -855,4 +865,6 @@ public abstract class Launcher { * Debug option to display full current path instead of just the last token. */ public static boolean showFullPath = false; + + private static final Logger LOGGER = Logger.getLogger(Launcher.class.getName()); } diff --git a/core/src/main/java/hudson/slaves/CommandLauncher.java b/core/src/main/java/hudson/slaves/CommandLauncher.java index d985a4ab49..146e382f67 100644 --- a/core/src/main/java/hudson/slaves/CommandLauncher.java +++ b/core/src/main/java/hudson/slaves/CommandLauncher.java @@ -124,7 +124,11 @@ public class CommandLauncher extends ComputerLauncher { cause.printStackTrace( listener.error(hudson.model.Messages.Slave_Terminated(getTimestamp()))); } - ProcessTree.get().killAll(proc, cookie); + try { + ProcessTree.get().killAll(proc, cookie); + } catch (InterruptedException e) { + LOGGER.log(Level.INFO, "interrupted", e); + } } }); @@ -149,7 +153,11 @@ public class CommandLauncher extends ComputerLauncher { e.printStackTrace(listener.error(msg)); if(_proc!=null) - ProcessTree.get().killAll(_proc, _cookie); + try { + ProcessTree.get().killAll(_proc, _cookie); + } catch (InterruptedException x) { + x.printStackTrace(listener.error(Messages.ComputerLauncher_abortedLaunch())); + } } } diff --git a/core/src/main/java/hudson/util/ProcessTreeKiller.java b/core/src/main/java/hudson/util/ProcessTreeKiller.java index 1232565387..ddbe00c694 100644 --- a/core/src/main/java/hudson/util/ProcessTreeKiller.java +++ b/core/src/main/java/hudson/util/ProcessTreeKiller.java @@ -41,7 +41,7 @@ public final class ProcessTreeKiller { * * @deprecated Use {@link OSProcess#killRecursively()} */ - public void kill(Process proc) { + public void kill(Process proc) throws InterruptedException { kill(proc,null); } @@ -73,7 +73,7 @@ public final class ProcessTreeKiller { * If non-null, search-and-destroy will be performed. * @deprecated Use {@link ProcessTree#killAll(Map)} and {@link OSProcess#killRecursively()} */ - public void kill(Process proc, Map modelEnvVars) { + public void kill(Process proc, Map modelEnvVars) throws InterruptedException { ProcessTree pt = ProcessTree.get(); if(proc!=null) pt.get(proc).killRecursively(); @@ -85,7 +85,7 @@ public final class ProcessTreeKiller { * Short for {@code kill(null,modelEnvVars)} * @deprecated Use {@link ProcessTree#killAll(Map)} */ - public void kill(Map modelEnvVars) { + public void kill(Map modelEnvVars) throws InterruptedException { kill(null,modelEnvVars); }