[
https://issues.apache.org/jira/browse/EXEC-42?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12875757#action_12875757
]
Konrad Windszus commented on EXEC-42:
-------------------------------------
Thanks for the update, some suggestions:
1. Fix the javadoc in the DefaultExecuteResultHandler.hasResult. The return
value is true, if the process was finished, not the other way round.
2. Add a link to the javadoc of java.lang.Process which explains, why writes to
stdout and stderr might be blocking, if you don't use the PumpStreamHandler,
altough this is mentioned in the tutorial section, the link might be helpful
for a more in depth information.
3. Add code for checking if process still running and also an example how to
destroy the process if necessary
{code}
while (!resultHandler.hasResult()) {
Thread.sleep(SLEEP_TIME_MS);
if (interruptProcess) {
watchdog.destroyProcess();
}
}
exitCode = resultHandler.getExitValue();
{code}
SLEEP_TIME_MS is a constant which specifies the wait interval in milliseconds
between the checks. In this example interruptProcess is a boolean variable,
which might be set to interrupt the process. It would be helpful if you could
add these lines in the tutorial example.
4. Add a hint in javadoc of Executor.execute that an exception is also thrown
when the process has an invalid exit code (which is not allowed via
Executor.setExitValue(s)).
5. Add a hint in javadoc in the ExecuteWatchdog, that it might be attached to
the process after the DefaultExecutor.execute has returned. Also add that hint
to all asynchronous Executor.execute methods.
> Tutorial should include example for asynchronous handling
> ---------------------------------------------------------
>
> Key: EXEC-42
> URL: https://issues.apache.org/jira/browse/EXEC-42
> Project: Commons Exec
> Issue Type: Improvement
> Affects Versions: 1.0, 1.0.1
> Reporter: Konrad Windszus
> Assignee: Siegfried Goeschl
> Fix For: 1.1
>
>
> I had some difficulties figuring out, how to asynchronously start a process.
> You should include an example for this on the tutorial page. Especially
> interesting is the following:
> - How to start it (explain ExecuteResultHandler and that the callbacks are
> called from another thread, so these should be implemented thread-safe)
> - How to know if it is still running (not possible via watchdog, but has to
> be implemented for oneself using the ExecuteResultHandler, again watch out
> for thread safety)
> - How to force to terminate a process (using the watchdog)
> - Add a hint about StreamHandler and that you should always use a
> PumpStreamHandler (otherwise this could lead to deadlocks, see
> http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html?).
> - Add an explanation of exit values, since an exit value which is not in the
> list of the DefaultExecutor, leads automatically to an exception, which is
> not clear from the javadocs.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.