Return-Path: Delivered-To: apmail-commons-issues-archive@minotaur.apache.org Received: (qmail 15807 invoked from network); 14 Aug 2010 19:35:41 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 14 Aug 2010 19:35:41 -0000 Received: (qmail 5675 invoked by uid 500); 14 Aug 2010 19:35:41 -0000 Delivered-To: apmail-commons-issues-archive@commons.apache.org Received: (qmail 5526 invoked by uid 500); 14 Aug 2010 19:35:40 -0000 Mailing-List: contact issues-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: issues@commons.apache.org Delivered-To: mailing list issues@commons.apache.org Received: (qmail 5513 invoked by uid 99); 14 Aug 2010 19:35:40 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 14 Aug 2010 19:35:39 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.22] (HELO thor.apache.org) (140.211.11.22) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 14 Aug 2010 19:35:39 +0000 Received: from thor (localhost [127.0.0.1]) by thor.apache.org (8.13.8+Sun/8.13.8) with ESMTP id o7EJZIVN025255 for ; Sat, 14 Aug 2010 19:35:19 GMT Message-ID: <21145231.351121281814518978.JavaMail.jira@thor> Date: Sat, 14 Aug 2010 15:35:18 -0400 (EDT) From: "Siegfried Goeschl (JIRA)" To: issues@commons.apache.org Subject: [jira] Commented: (EXEC-34) Race condition prevent watchdog working using ExecuteStreamHandler In-Reply-To: <452079765.1231172504519.JavaMail.jira@brutus> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/EXEC-34?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12898631#action_12898631 ] Siegfried Goeschl commented on EXEC-34: --------------------------------------- Well, actually the sample is buggy since the following line is missing exec.setWatchdog(watchdog) which injects the newly created 'Process' instance into the watchdog and without *Process' instance 'watchdog.destroy()' has no effect > Race condition prevent watchdog working using ExecuteStreamHandler > ------------------------------------------------------------------ > > Key: EXEC-34 > URL: https://issues.apache.org/jira/browse/EXEC-34 > Project: Commons Exec > Issue Type: Bug > Environment: Windows Vista 64bit, dual core CPU > Reporter: Marco Ferrante > Assignee: Siegfried Goeschl > Priority: Minor > > Consider this test case (in _DefaultExecutorTest_ class): > {noformat} > /** > * Start a async process using a stream handler and terminate it manually > * before the watchdog timeout occurs > */ > public void testExecuteAsyncWithStreamHandlerAndUserTermination() throws Exception { > CommandLine cl = new CommandLine(foreverTestScript); > ExecuteWatchdog watchdog = new ExecuteWatchdog(Integer.MAX_VALUE); > PumpStreamHandler streamHanlder = new PumpStreamHandler(System.out, System.err); > exec.setStreamHandler(streamHanlder); > MockExecuteResultHandler handler = new MockExecuteResultHandler(); > exec.execute(cl, handler); > // DON'T wait for script to run > //Thread.sleep(2000); > // teminate it > watchdog.destroyProcess(); > assertTrue("Watchdog should have killed the process",watchdog.killedProcess()); > } > {noformat} > It fails (at least in my environment) because when _watchdog.destroyProcess()_ is invoked the external process is not bound to the watchdog yet. > Although there are possible several workarounds, but all of them seem to me very intrusive in the code. So, I prefer some discussion before preparing and submitting a patch. > IMHO, the watchdog should handle a reference to the thread running the process, not to the process itself. In this way, interrupting signals can be transport using default _interrupt()_ method of class _Thread_. -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.