ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Hal Hildebrand \(web\)" <Hal.Hildebr...@hellblazer.com>
Subject Taskdef warnings and ^C fix
Date Mon, 06 May 2002 23:29:20 GMT
Couple of things.  If this is the wrong emailing list for this, please
let me know.

First, in 1.5 beta1, if you try to re-define an Ant taskdef in another
project you will get an annoying warning in the log file.  Basically, I
have a situation where I define tasks in include files, so this means
that there's a number of the same tasks with the same class names being
defined.  In 1.4.1, this was ignored, although in verbose output it
would be logged.  In looking at the code, the problem is that the
classes are being compared, and since the apparently come from different
classloaders, the classes don't compare .equals(), thus the error
message.

Second problem is with the exec().  In JDK 1.4, I don't know what they
did, but when you ^C a java process, the exec'd processes (i.e. the
child processes) are no longer killed.  Thus if you use ant to start up
Java processes, they are no longer killed if you ^C the Ant process that
spawned them.

The fix we've been using is to use the shutdown hook of the VM to
destroy the spawned processes on exit.  For example, in Exec.run(),

            // exec command on system runtime
            Process proc = Runtime.getRuntime().exec(command);

            // kill me if Ctrl-C the process
            ProcessKiller killer = new ProcessKiller(proc);
            Runtime.getRuntime().addShutdownHook(killer);

Where ProcessKiller is simply:


    class ProcessKiller extends Thread {

        Process process;

        ProcessKiller(Process process) {
            this.process = process;
        }

        public void run() {
            process.destroy();
        }
    }


It's incredibly annoying on WinXP to have these processes constantly
lying about.  I think it's great that the JDK 1.4 doesn't kill the
spawned processes now, but the result is that ^C'ing Ant no longer kills
the processes.

Again, if this is the wrong list, just yell at me...

Cheers,

-Hal
______
science does not remove the terror of the gods
www.hellblazer.com


--
To unsubscribe, e-mail:   <mailto:ant-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-user-help@jakarta.apache.org>


Mime
View raw message