commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mishkin, Ernest" <ernest_mish...@mcgraw-hill.com>
Subject ExecuteWatchdog does not really terminate the "hung" process?
Date Mon, 22 Jun 2009 13:36:40 GMT
Hello,

I have a simple test case which involves starting a .bat file which
tries to simulate a process "stuck for N seconds" by executing
ping -n %1 -w 1000 127.0.0.1

I invoke this from java using DefaultExcutor, passing "10" as an
argument to .bat file (so that it will run 10 approx. 1 sec pings
resulting in close to 10 sec wait).
I'm also setting ExecuteWatchdog with a 2 sec timeout.
Problem is, my execute call does not return until ~ 10 seconds later, as
measured by System.currentTimeMillis().
The watchdog confirms that it "killed" the process however the expected
behavior is that execute() call gets interrupted after 2 secs and it
wasn't.

The complete source code is attached. 

Please help me understand: am I missing something fundamental, have I
found an issue, or something else?


If developer(s) are lurking on this list, I'd like to mention that it
seems like when ExecuteWatchdog detects a timeout it should interrupt
the "primary" thread (the one which runs code from
DefaultExecutor::executeInternal, in particular the lines below:
            try {
                exitValue = process.waitFor();
            } catch (InterruptedException e) {
                process.destroy();
            }
process.waitFor() blocks, and it seems that when process.destroy() is
called from the watchdog thread the other thread which is stuck in
process.waitFor() is not released.
That's why having DefaultWatchdog maintain a reference to the executor's
thread and interrupt()'ing it might be helpful.



Sincerely,
Ernest Mishkin
 
--------------------------------------------------------

The information contained in this message is intended only for the recipient, and may be a
confidential attorney-client communication or may otherwise be privileged and confidential
and protected from disclosure. If the reader of this message is not the intended recipient,
or an employee or agent responsible for delivering this message to the intended recipient,
please be aware that any dissemination or copying of this communication is strictly prohibited.
If you have received this communication in error, please immediately notify us by replying
to the message and deleting it from your computer. The McGraw-Hill Companies, Inc. reserves
the right, subject to applicable local law, to monitor and review the content of any electronic
message or information sent to or from McGraw-Hill employee e-mail addresses without informing
the sender or recipient of the message.
--------------------------------------------------------


Mime
View raw message