You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Richard Atkins (JIRA)" <ji...@apache.org> on 2012/11/04 05:55:12 UTC

[jira] [Created] (EXEC-69) DefaultExecutor async execute prevents shutdown hooks running

Richard Atkins created EXEC-69:
----------------------------------

             Summary: DefaultExecutor async execute prevents shutdown hooks running
                 Key: EXEC-69
                 URL: https://issues.apache.org/jira/browse/EXEC-69
             Project: Commons Exec
          Issue Type: Bug
    Affects Versions: 1.1
            Reporter: Richard Atkins


The DefaultExecutor asynchronous execute methods create a user-level thread to monitor the process it starts. This prevents shutdown hooks - like the one in ShutdownHookProcessDestroyer - from running. This makes these two classes incompatible.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Updated] (EXEC-69) DefaultExecutor async execute prevents shutdown hooks running

Posted by "Richard Atkins (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/EXEC-69?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Richard Atkins updated EXEC-69:
-------------------------------

    Attachment: DaemonExecutor.java

Attached is a very simple fix for this: it's a subclass of DefaultExecutor that creates daemon threads in the createThread() factory method. Library users will have to select this class, rather than DefaultExecutor, in order to take advantage of it.
                
> DefaultExecutor async execute prevents shutdown hooks running
> -------------------------------------------------------------
>
>                 Key: EXEC-69
>                 URL: https://issues.apache.org/jira/browse/EXEC-69
>             Project: Commons Exec
>          Issue Type: Bug
>    Affects Versions: 1.1
>            Reporter: Richard Atkins
>         Attachments: DaemonExecutor.java
>
>
> The DefaultExecutor asynchronous execute methods create a user-level thread to monitor the process it starts. This prevents shutdown hooks - like the one in ShutdownHookProcessDestroyer - from running. This makes these two classes incompatible.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (EXEC-69) DefaultExecutor async execute prevents shutdown hooks running

Posted by "Richard Atkins (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/EXEC-69?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13490142#comment-13490142 ] 

Richard Atkins commented on EXEC-69:
------------------------------------

The simplest fix is to let a ShutdownHookProcessDestroyer do its job is to set the asynchronous executors' thread to be a daemon thread, although I don't believe that's a blanket solution for all async exec use cases. Sometimes callers really don't want to exit unless the child process is already done (and the result handler has finished handling the result).

The answer lies in pushing that decision back on the caller - they either configure their own thread factory (assuming https://issues.apache.org/jira/browse/EXEC-70 is implemented) to choose if the threads should be user level or daemon level, or we do it for them, based on whether there's a process destroyer registered.

The recent change on trunk to use a createThread factory method gets us part of the way there for either solution.
                
> DefaultExecutor async execute prevents shutdown hooks running
> -------------------------------------------------------------
>
>                 Key: EXEC-69
>                 URL: https://issues.apache.org/jira/browse/EXEC-69
>             Project: Commons Exec
>          Issue Type: Bug
>    Affects Versions: 1.1
>            Reporter: Richard Atkins
>
> The DefaultExecutor asynchronous execute methods create a user-level thread to monitor the process it starts. This prevents shutdown hooks - like the one in ShutdownHookProcessDestroyer - from running. This makes these two classes incompatible.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira