From a6c64aa1669d5158395cc1f2f4954e91307e316f Mon Sep 17 00:00:00 2001 From: Stefan Bodewig Date: Wed, 31 Jan 2001 15:55:47 +0000 Subject: [PATCH] Make sure the watched process is running before we kill it. Submitted by: Stephane Bailliez git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@268548 13f79535-47bb-0310-9956-ffa450edef68 --- .../tools/ant/taskdefs/ExecuteWatchdog.java | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/main/org/apache/tools/ant/taskdefs/ExecuteWatchdog.java b/src/main/org/apache/tools/ant/taskdefs/ExecuteWatchdog.java index 1d757bdcc..7a9766409 100644 --- a/src/main/org/apache/tools/ant/taskdefs/ExecuteWatchdog.java +++ b/src/main/org/apache/tools/ant/taskdefs/ExecuteWatchdog.java @@ -147,11 +147,21 @@ public class ExecuteWatchdog implements Runnable { wait(until - now); } catch (InterruptedException e) {} } - // if we are here, either someone stopped the watchdog or we are on timeout - // if watch is true, it means its a timeout - if (watch) { - killedProcess = true; - process.destroy(); + + // if we are here, either someone stopped the watchdog, + // we are on timeout and the process must be killed, or + // we are on timeout and the process has already stopped. + try { + // We must check if the process was not stopped + // before being here + process.exitValue(); + } catch (IllegalThreadStateException e){ + // the process is not terminated, if this is really + // a timeout and not a manual stop then kill it. + if (watch){ + killedProcess = true; + process.destroy(); + } } } catch(Exception e) { caught = e;