mirror of
https://github.com/jenkinsci/jenkins.git
synced 2026-11-08 01:26:03 +00:00
integrated winp so that Hudson can kill processes recursively on Windows.
git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@7016 71c3de6d-444a-0410-be80-ed276b4c234a
This commit is contained in:
1 parent
66f9720fde
commit
bda15d2acb
4 files changed
+31
-4
No files matched your search
@@ -21,6 +21,8 @@ import java.io.BufferedOutputStream;
|
||||
import java.util.Map;
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.jvnet.winp.WinProcess;
|
||||
|
||||
/**
|
||||
* Starts a process.
|
||||
*
|
||||
@@ -310,7 +312,10 @@ public abstract class Launcher {
|
||||
*/
|
||||
protected synchronized void terminate(IOException e) {
|
||||
super.terminate(e);
|
||||
proc.destroy();
|
||||
if(Hudson.isWindows())
|
||||
new WinProcess(proc).killRecursively();
|
||||
else
|
||||
proc.destroy();
|
||||
}
|
||||
|
||||
public synchronized void close() throws IOException {
|
||||
|
||||
@@ -3,6 +3,7 @@ package hudson;
|
||||
import hudson.remoting.Channel;
|
||||
import hudson.util.IOException2;
|
||||
import hudson.util.StreamCopyThread;
|
||||
import hudson.model.Hudson;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@@ -14,6 +15,8 @@ import java.util.concurrent.Future;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.jvnet.winp.WinProcess;
|
||||
|
||||
/**
|
||||
* External process wrapper.
|
||||
*
|
||||
@@ -144,17 +147,27 @@ public abstract class Proc {
|
||||
return r;
|
||||
} catch (InterruptedException e) {
|
||||
// aborting. kill the process
|
||||
proc.destroy();
|
||||
destroy();
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void kill() throws InterruptedException, IOException {
|
||||
proc.destroy();
|
||||
destroy();
|
||||
join();
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroys the child process without join.
|
||||
*/
|
||||
private void destroy() {
|
||||
if(Hudson.isWindows())
|
||||
new WinProcess(proc).killRecursively();
|
||||
else
|
||||
proc.destroy();
|
||||
}
|
||||
|
||||
private static class ByteCopier extends Thread {
|
||||
private final InputStream in;
|
||||
private final OutputStream out;
|
||||
|
||||
@@ -17,6 +17,7 @@ import hudson.tasks.LabelFinder;
|
||||
import hudson.util.*;
|
||||
import org.kohsuke.stapler.StaplerRequest;
|
||||
import org.kohsuke.stapler.StaplerResponse;
|
||||
import org.jvnet.winp.WinProcess;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
@@ -315,7 +316,10 @@ public final class Slave implements Node, Serializable {
|
||||
public void onClosed(Channel channel, IOException cause) {
|
||||
if(cause!=null)
|
||||
cause.printStackTrace(listener.error("%s slave agent was terminated\n",getTimestamp()));
|
||||
proc.destroy();
|
||||
if(Hudson.isWindows())
|
||||
new WinProcess(proc).killRecursively();
|
||||
else
|
||||
proc.destroy();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in new issue
Block a user