[jira] Created: (EXEC-57) DefaultExecutor.execute() does not return even if child process terminated

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

[jira] Created: (EXEC-57) DefaultExecutor.execute() does not return even if child process terminated

Gilles (Jira)
DefaultExecutor.execute() does not return even if child process terminated
--------------------------------------------------------------------------

                 Key: EXEC-57
                 URL: https://issues.apache.org/jira/browse/EXEC-57
             Project: Commons Exec
          Issue Type: Bug
    Affects Versions: 1.1
         Environment: > uname -smr
HP-UX B.11.23 ia64

$ uname -smr
Linux 2.6.18-194.3.1.el5xen x86_64


            Reporter: Nickolay Martinov


When script that starts background process is synchronously executed via DefaultExecutor.execute() then method never returns (until child process spawned by child process terminates).

Here is example if such script:

echo "Going to start daemon process"
sleep 1
cd ./target
nohup sleep 10 &
sleep 1
echo "Daemon process was started"

Stream handler is used to grab and print output of script. As can be seen from stack trace problem lies in pump threads that call InputStream.read() that does not return when script that we invoke terminates. Instead it returns only once process started by script terminates.

"Thread-3" daemon prio=10 tid=00c73a00 nid=17 lwp_id=2640638 runnable [2e180000]
   java.lang.Thread.State: RUNNABLE
        at java.io.FileInputStream.readBytes(Native Method)
        at java.io.FileInputStream.read(FileInputStream.java:177)
        at java.lang.UNIXProcess$DeferredCloseInputStream.read(UNIXProcess.java:313)
        at org.apache.commons.exec.StreamPumper.run(StreamPumper.java:105)
        at java.lang.Thread.run(Thread.java:662)

   Locked ownable synchronizers:
        - None

"Thread-2" daemon prio=10 tid=005fd000 nid=16 lwp_id=2640637 runnable [2e240000]
   java.lang.Thread.State: RUNNABLE
        at java.io.FileInputStream.readBytes(Native Method)
        at java.io.FileInputStream.read(FileInputStream.java:199)
        at java.lang.UNIXProcess$DeferredCloseInputStream.read(UNIXProcess.java:322)
        at java.io.BufferedInputStream.fill(BufferedInputStream.java:218)
        at java.io.BufferedInputStream.read1(BufferedInputStream.java:258)
        at java.io.BufferedInputStream.read(BufferedInputStream.java:317)
        - locked <628b1970> (a java.io.BufferedInputStream)
        at java.io.FilterInputStream.read(FilterInputStream.java:90)
        at org.apache.commons.exec.StreamPumper.run(StreamPumper.java:105)
        at java.lang.Thread.run(Thread.java:662)

   Locked ownable synchronizers:
        - None

"main" prio=10 tid=0046aa00 nid=1 lwp_id=-1 in Object.wait() [7fff8000]
   java.lang.Thread.State: WAITING (on object monitor)
        at java.lang.Object.wait(Native Method)
        - waiting on <627e4968> (a java.lang.Thread)
        at java.lang.Thread.join(Thread.java:1186)
        - locked <627e4968> (a java.lang.Thread)
        at java.lang.Thread.join(Thread.java:1239)
        at org.apache.commons.exec.PumpStreamHandler.stop(PumpStreamHandler.java:171)
        at org.apache.commons.exec.DefaultExecutor.executeInternal(DefaultExecutor.java:363)
        at org.apache.commons.exec.DefaultExecutor.execute(DefaultExecutor.java:160)
        at org.apache.commons.exec.DefaultExecutor.execute(DefaultExecutor.java:147)

I added timeout to join() and call interrupt() but that doesnt help to kill pump threads. Fortunately, these are daemon threads that do not block JVM from exiting. Except from extra daemon threads this solved problem on linux. But that wasnt able to prevent all hangs on HP-UX. Check following stack

"main" prio=10 tid=00465600 nid=1 lwp_id=-1 runnable [7fffd000]
   java.lang.Thread.State: RUNNABLE
        at java.io.FileInputStream.close0(Native Method)
        at java.io.FileInputStream.close(FileInputStream.java:259)
        at java.lang.UNIXProcess$DeferredCloseInputStream.close(UNIXProcess.java:298)
        at java.io.BufferedInputStream.close(BufferedInputStream.java:451)
        at org.apache.commons.exec.DefaultExecutor.closeStreams(DefaultExecutor.java:281)
        at org.apache.commons.exec.DefaultExecutor.executeInternal(DefaultExecutor.java:364)
        at org.apache.commons.exec.DefaultExecutor.execute(DefaultExecutor.java:160)
        at org.apache.commons.exec.DefaultExecutor.execute(DefaultExecutor.java:147)
        at org.apache.commons.exec.DefaultExecutorTest.testSyncInvocationOfBackgroundProcess(DefaultExecutorTest.java:812)

I dont have idea how this can be interrupted or timed out except that skip closing streams. But in this case we'll probably leak resources.

--
This message is automatically generated by JIRA.
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

       
Reply | Threaded
Open this post in threaded view
|

[jira] Updated: (EXEC-57) DefaultExecutor.execute() does not return even if child process terminated

Gilles (Jira)

     [ https://issues.apache.org/jira/browse/EXEC-57?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Nickolay Martinov updated EXEC-57:
----------------------------------

    Attachment: EXEC-57.test.patch

Added patch that solves problem to some degree on Linux and demonstrates problem on HP-UX.

> DefaultExecutor.execute() does not return even if child process terminated
> --------------------------------------------------------------------------
>
>                 Key: EXEC-57
>                 URL: https://issues.apache.org/jira/browse/EXEC-57
>             Project: Commons Exec
>          Issue Type: Bug
>    Affects Versions: 1.1
>         Environment: > uname -smr
> HP-UX B.11.23 ia64
> $ uname -smr
> Linux 2.6.18-194.3.1.el5xen x86_64
>            Reporter: Nickolay Martinov
>         Attachments: EXEC-57.test.patch
>
>
> When script that starts background process is synchronously executed via DefaultExecutor.execute() then method never returns (until child process spawned by child process terminates).
> Here is example if such script:
> echo "Going to start daemon process"
> sleep 1
> cd ./target
> nohup sleep 10 &
> sleep 1
> echo "Daemon process was started"
> Stream handler is used to grab and print output of script. As can be seen from stack trace problem lies in pump threads that call InputStream.read() that does not return when script that we invoke terminates. Instead it returns only once process started by script terminates.
> "Thread-3" daemon prio=10 tid=00c73a00 nid=17 lwp_id=2640638 runnable [2e180000]
>    java.lang.Thread.State: RUNNABLE
>         at java.io.FileInputStream.readBytes(Native Method)
>         at java.io.FileInputStream.read(FileInputStream.java:177)
>         at java.lang.UNIXProcess$DeferredCloseInputStream.read(UNIXProcess.java:313)
>         at org.apache.commons.exec.StreamPumper.run(StreamPumper.java:105)
>         at java.lang.Thread.run(Thread.java:662)
>    Locked ownable synchronizers:
>         - None
> "Thread-2" daemon prio=10 tid=005fd000 nid=16 lwp_id=2640637 runnable [2e240000]
>    java.lang.Thread.State: RUNNABLE
>         at java.io.FileInputStream.readBytes(Native Method)
>         at java.io.FileInputStream.read(FileInputStream.java:199)
>         at java.lang.UNIXProcess$DeferredCloseInputStream.read(UNIXProcess.java:322)
>         at java.io.BufferedInputStream.fill(BufferedInputStream.java:218)
>         at java.io.BufferedInputStream.read1(BufferedInputStream.java:258)
>         at java.io.BufferedInputStream.read(BufferedInputStream.java:317)
>         - locked <628b1970> (a java.io.BufferedInputStream)
>         at java.io.FilterInputStream.read(FilterInputStream.java:90)
>         at org.apache.commons.exec.StreamPumper.run(StreamPumper.java:105)
>         at java.lang.Thread.run(Thread.java:662)
>    Locked ownable synchronizers:
>         - None
> "main" prio=10 tid=0046aa00 nid=1 lwp_id=-1 in Object.wait() [7fff8000]
>    java.lang.Thread.State: WAITING (on object monitor)
>         at java.lang.Object.wait(Native Method)
>         - waiting on <627e4968> (a java.lang.Thread)
>         at java.lang.Thread.join(Thread.java:1186)
>         - locked <627e4968> (a java.lang.Thread)
>         at java.lang.Thread.join(Thread.java:1239)
>         at org.apache.commons.exec.PumpStreamHandler.stop(PumpStreamHandler.java:171)
>         at org.apache.commons.exec.DefaultExecutor.executeInternal(DefaultExecutor.java:363)
>         at org.apache.commons.exec.DefaultExecutor.execute(DefaultExecutor.java:160)
>         at org.apache.commons.exec.DefaultExecutor.execute(DefaultExecutor.java:147)
> I added timeout to join() and call interrupt() but that doesnt help to kill pump threads. Fortunately, these are daemon threads that do not block JVM from exiting. Except from extra daemon threads this solved problem on linux. But that wasnt able to prevent all hangs on HP-UX. Check following stack
> "main" prio=10 tid=00465600 nid=1 lwp_id=-1 runnable [7fffd000]
>    java.lang.Thread.State: RUNNABLE
>         at java.io.FileInputStream.close0(Native Method)
>         at java.io.FileInputStream.close(FileInputStream.java:259)
>         at java.lang.UNIXProcess$DeferredCloseInputStream.close(UNIXProcess.java:298)
>         at java.io.BufferedInputStream.close(BufferedInputStream.java:451)
>         at org.apache.commons.exec.DefaultExecutor.closeStreams(DefaultExecutor.java:281)
>         at org.apache.commons.exec.DefaultExecutor.executeInternal(DefaultExecutor.java:364)
>         at org.apache.commons.exec.DefaultExecutor.execute(DefaultExecutor.java:160)
>         at org.apache.commons.exec.DefaultExecutor.execute(DefaultExecutor.java:147)
>         at org.apache.commons.exec.DefaultExecutorTest.testSyncInvocationOfBackgroundProcess(DefaultExecutorTest.java:812)
> I dont have idea how this can be interrupted or timed out except that skip closing streams. But in this case we'll probably leak resources.

--
This message is automatically generated by JIRA.
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

       
Reply | Threaded
Open this post in threaded view
|

[jira] [Commented] (EXEC-57) DefaultExecutor.execute() does not return even if child process terminated

Gilles (Jira)
In reply to this post by Gilles (Jira)

    [ https://issues.apache.org/jira/browse/EXEC-57?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13124441#comment-13124441 ]

Siegfried Goeschl commented on EXEC-57:
---------------------------------------

I'm not sure if this problem is caused by commons-exec and the patch actually disguises the problem - not sure how to proceed
               

> DefaultExecutor.execute() does not return even if child process terminated
> --------------------------------------------------------------------------
>
>                 Key: EXEC-57
>                 URL: https://issues.apache.org/jira/browse/EXEC-57
>             Project: Commons Exec
>          Issue Type: Bug
>    Affects Versions: 1.1
>         Environment: > uname -smr
> HP-UX B.11.23 ia64
> $ uname -smr
> Linux 2.6.18-194.3.1.el5xen x86_64
>            Reporter: Nickolay Martinov
>            Assignee: Siegfried Goeschl
>         Attachments: EXEC-57.test.patch
>
>
> When script that starts background process is synchronously executed via DefaultExecutor.execute() then method never returns (until child process spawned by child process terminates).
> Here is example if such script:
> echo "Going to start daemon process"
> sleep 1
> cd ./target
> nohup sleep 10 &
> sleep 1
> echo "Daemon process was started"
> Stream handler is used to grab and print output of script. As can be seen from stack trace problem lies in pump threads that call InputStream.read() that does not return when script that we invoke terminates. Instead it returns only once process started by script terminates.
> "Thread-3" daemon prio=10 tid=00c73a00 nid=17 lwp_id=2640638 runnable [2e180000]
>    java.lang.Thread.State: RUNNABLE
>         at java.io.FileInputStream.readBytes(Native Method)
>         at java.io.FileInputStream.read(FileInputStream.java:177)
>         at java.lang.UNIXProcess$DeferredCloseInputStream.read(UNIXProcess.java:313)
>         at org.apache.commons.exec.StreamPumper.run(StreamPumper.java:105)
>         at java.lang.Thread.run(Thread.java:662)
>    Locked ownable synchronizers:
>         - None
> "Thread-2" daemon prio=10 tid=005fd000 nid=16 lwp_id=2640637 runnable [2e240000]
>    java.lang.Thread.State: RUNNABLE
>         at java.io.FileInputStream.readBytes(Native Method)
>         at java.io.FileInputStream.read(FileInputStream.java:199)
>         at java.lang.UNIXProcess$DeferredCloseInputStream.read(UNIXProcess.java:322)
>         at java.io.BufferedInputStream.fill(BufferedInputStream.java:218)
>         at java.io.BufferedInputStream.read1(BufferedInputStream.java:258)
>         at java.io.BufferedInputStream.read(BufferedInputStream.java:317)
>         - locked <628b1970> (a java.io.BufferedInputStream)
>         at java.io.FilterInputStream.read(FilterInputStream.java:90)
>         at org.apache.commons.exec.StreamPumper.run(StreamPumper.java:105)
>         at java.lang.Thread.run(Thread.java:662)
>    Locked ownable synchronizers:
>         - None
> "main" prio=10 tid=0046aa00 nid=1 lwp_id=-1 in Object.wait() [7fff8000]
>    java.lang.Thread.State: WAITING (on object monitor)
>         at java.lang.Object.wait(Native Method)
>         - waiting on <627e4968> (a java.lang.Thread)
>         at java.lang.Thread.join(Thread.java:1186)
>         - locked <627e4968> (a java.lang.Thread)
>         at java.lang.Thread.join(Thread.java:1239)
>         at org.apache.commons.exec.PumpStreamHandler.stop(PumpStreamHandler.java:171)
>         at org.apache.commons.exec.DefaultExecutor.executeInternal(DefaultExecutor.java:363)
>         at org.apache.commons.exec.DefaultExecutor.execute(DefaultExecutor.java:160)
>         at org.apache.commons.exec.DefaultExecutor.execute(DefaultExecutor.java:147)
> I added timeout to join() and call interrupt() but that doesnt help to kill pump threads. Fortunately, these are daemon threads that do not block JVM from exiting. Except from extra daemon threads this solved problem on linux. But that wasnt able to prevent all hangs on HP-UX. Check following stack
> "main" prio=10 tid=00465600 nid=1 lwp_id=-1 runnable [7fffd000]
>    java.lang.Thread.State: RUNNABLE
>         at java.io.FileInputStream.close0(Native Method)
>         at java.io.FileInputStream.close(FileInputStream.java:259)
>         at java.lang.UNIXProcess$DeferredCloseInputStream.close(UNIXProcess.java:298)
>         at java.io.BufferedInputStream.close(BufferedInputStream.java:451)
>         at org.apache.commons.exec.DefaultExecutor.closeStreams(DefaultExecutor.java:281)
>         at org.apache.commons.exec.DefaultExecutor.executeInternal(DefaultExecutor.java:364)
>         at org.apache.commons.exec.DefaultExecutor.execute(DefaultExecutor.java:160)
>         at org.apache.commons.exec.DefaultExecutor.execute(DefaultExecutor.java:147)
>         at org.apache.commons.exec.DefaultExecutorTest.testSyncInvocationOfBackgroundProcess(DefaultExecutorTest.java:812)
> I dont have idea how this can be interrupted or timed out except that skip closing streams. But in this case we'll probably leak resources.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

       
Reply | Threaded
Open this post in threaded view
|

[jira] [Commented] (EXEC-57) DefaultExecutor.execute() does not return even if child process terminated

Gilles (Jira)
In reply to this post by Gilles (Jira)

    [ https://issues.apache.org/jira/browse/EXEC-57?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13124475#comment-13124475 ]

Siegfried Goeschl commented on EXEC-57:
---------------------------------------

I think a found an okayish implementation - when the stop timeout is exceeded the implementation later throws an exception. In this case the caller knows that something went wrong.
               

> DefaultExecutor.execute() does not return even if child process terminated
> --------------------------------------------------------------------------
>
>                 Key: EXEC-57
>                 URL: https://issues.apache.org/jira/browse/EXEC-57
>             Project: Commons Exec
>          Issue Type: Bug
>    Affects Versions: 1.1
>         Environment: > uname -smr
> HP-UX B.11.23 ia64
> $ uname -smr
> Linux 2.6.18-194.3.1.el5xen x86_64
>            Reporter: Nickolay Martinov
>            Assignee: Siegfried Goeschl
>         Attachments: EXEC-57.test.patch
>
>
> When script that starts background process is synchronously executed via DefaultExecutor.execute() then method never returns (until child process spawned by child process terminates).
> Here is example if such script:
> echo "Going to start daemon process"
> sleep 1
> cd ./target
> nohup sleep 10 &
> sleep 1
> echo "Daemon process was started"
> Stream handler is used to grab and print output of script. As can be seen from stack trace problem lies in pump threads that call InputStream.read() that does not return when script that we invoke terminates. Instead it returns only once process started by script terminates.
> "Thread-3" daemon prio=10 tid=00c73a00 nid=17 lwp_id=2640638 runnable [2e180000]
>    java.lang.Thread.State: RUNNABLE
>         at java.io.FileInputStream.readBytes(Native Method)
>         at java.io.FileInputStream.read(FileInputStream.java:177)
>         at java.lang.UNIXProcess$DeferredCloseInputStream.read(UNIXProcess.java:313)
>         at org.apache.commons.exec.StreamPumper.run(StreamPumper.java:105)
>         at java.lang.Thread.run(Thread.java:662)
>    Locked ownable synchronizers:
>         - None
> "Thread-2" daemon prio=10 tid=005fd000 nid=16 lwp_id=2640637 runnable [2e240000]
>    java.lang.Thread.State: RUNNABLE
>         at java.io.FileInputStream.readBytes(Native Method)
>         at java.io.FileInputStream.read(FileInputStream.java:199)
>         at java.lang.UNIXProcess$DeferredCloseInputStream.read(UNIXProcess.java:322)
>         at java.io.BufferedInputStream.fill(BufferedInputStream.java:218)
>         at java.io.BufferedInputStream.read1(BufferedInputStream.java:258)
>         at java.io.BufferedInputStream.read(BufferedInputStream.java:317)
>         - locked <628b1970> (a java.io.BufferedInputStream)
>         at java.io.FilterInputStream.read(FilterInputStream.java:90)
>         at org.apache.commons.exec.StreamPumper.run(StreamPumper.java:105)
>         at java.lang.Thread.run(Thread.java:662)
>    Locked ownable synchronizers:
>         - None
> "main" prio=10 tid=0046aa00 nid=1 lwp_id=-1 in Object.wait() [7fff8000]
>    java.lang.Thread.State: WAITING (on object monitor)
>         at java.lang.Object.wait(Native Method)
>         - waiting on <627e4968> (a java.lang.Thread)
>         at java.lang.Thread.join(Thread.java:1186)
>         - locked <627e4968> (a java.lang.Thread)
>         at java.lang.Thread.join(Thread.java:1239)
>         at org.apache.commons.exec.PumpStreamHandler.stop(PumpStreamHandler.java:171)
>         at org.apache.commons.exec.DefaultExecutor.executeInternal(DefaultExecutor.java:363)
>         at org.apache.commons.exec.DefaultExecutor.execute(DefaultExecutor.java:160)
>         at org.apache.commons.exec.DefaultExecutor.execute(DefaultExecutor.java:147)
> I added timeout to join() and call interrupt() but that doesnt help to kill pump threads. Fortunately, these are daemon threads that do not block JVM from exiting. Except from extra daemon threads this solved problem on linux. But that wasnt able to prevent all hangs on HP-UX. Check following stack
> "main" prio=10 tid=00465600 nid=1 lwp_id=-1 runnable [7fffd000]
>    java.lang.Thread.State: RUNNABLE
>         at java.io.FileInputStream.close0(Native Method)
>         at java.io.FileInputStream.close(FileInputStream.java:259)
>         at java.lang.UNIXProcess$DeferredCloseInputStream.close(UNIXProcess.java:298)
>         at java.io.BufferedInputStream.close(BufferedInputStream.java:451)
>         at org.apache.commons.exec.DefaultExecutor.closeStreams(DefaultExecutor.java:281)
>         at org.apache.commons.exec.DefaultExecutor.executeInternal(DefaultExecutor.java:364)
>         at org.apache.commons.exec.DefaultExecutor.execute(DefaultExecutor.java:160)
>         at org.apache.commons.exec.DefaultExecutor.execute(DefaultExecutor.java:147)
>         at org.apache.commons.exec.DefaultExecutorTest.testSyncInvocationOfBackgroundProcess(DefaultExecutorTest.java:812)
> I dont have idea how this can be interrupted or timed out except that skip closing streams. But in this case we'll probably leak resources.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

       
Reply | Threaded
Open this post in threaded view
|

[jira] [Commented] (EXEC-57) DefaultExecutor.execute() does not return even if child process terminated

Gilles (Jira)
In reply to this post by Gilles (Jira)

    [ https://issues.apache.org/jira/browse/EXEC-57?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13124479#comment-13124479 ]

Siegfried Goeschl commented on EXEC-57:
---------------------------------------

BTW

nohup sleep 10 1>/dev/null 2>/dev/null 0</dev/null &

would work since the process would be really decoupled
               

> DefaultExecutor.execute() does not return even if child process terminated
> --------------------------------------------------------------------------
>
>                 Key: EXEC-57
>                 URL: https://issues.apache.org/jira/browse/EXEC-57
>             Project: Commons Exec
>          Issue Type: Bug
>    Affects Versions: 1.1
>         Environment: > uname -smr
> HP-UX B.11.23 ia64
> $ uname -smr
> Linux 2.6.18-194.3.1.el5xen x86_64
>            Reporter: Nickolay Martinov
>            Assignee: Siegfried Goeschl
>         Attachments: EXEC-57.test.patch
>
>
> When script that starts background process is synchronously executed via DefaultExecutor.execute() then method never returns (until child process spawned by child process terminates).
> Here is example if such script:
> echo "Going to start daemon process"
> sleep 1
> cd ./target
> nohup sleep 10 &
> sleep 1
> echo "Daemon process was started"
> Stream handler is used to grab and print output of script. As can be seen from stack trace problem lies in pump threads that call InputStream.read() that does not return when script that we invoke terminates. Instead it returns only once process started by script terminates.
> "Thread-3" daemon prio=10 tid=00c73a00 nid=17 lwp_id=2640638 runnable [2e180000]
>    java.lang.Thread.State: RUNNABLE
>         at java.io.FileInputStream.readBytes(Native Method)
>         at java.io.FileInputStream.read(FileInputStream.java:177)
>         at java.lang.UNIXProcess$DeferredCloseInputStream.read(UNIXProcess.java:313)
>         at org.apache.commons.exec.StreamPumper.run(StreamPumper.java:105)
>         at java.lang.Thread.run(Thread.java:662)
>    Locked ownable synchronizers:
>         - None
> "Thread-2" daemon prio=10 tid=005fd000 nid=16 lwp_id=2640637 runnable [2e240000]
>    java.lang.Thread.State: RUNNABLE
>         at java.io.FileInputStream.readBytes(Native Method)
>         at java.io.FileInputStream.read(FileInputStream.java:199)
>         at java.lang.UNIXProcess$DeferredCloseInputStream.read(UNIXProcess.java:322)
>         at java.io.BufferedInputStream.fill(BufferedInputStream.java:218)
>         at java.io.BufferedInputStream.read1(BufferedInputStream.java:258)
>         at java.io.BufferedInputStream.read(BufferedInputStream.java:317)
>         - locked <628b1970> (a java.io.BufferedInputStream)
>         at java.io.FilterInputStream.read(FilterInputStream.java:90)
>         at org.apache.commons.exec.StreamPumper.run(StreamPumper.java:105)
>         at java.lang.Thread.run(Thread.java:662)
>    Locked ownable synchronizers:
>         - None
> "main" prio=10 tid=0046aa00 nid=1 lwp_id=-1 in Object.wait() [7fff8000]
>    java.lang.Thread.State: WAITING (on object monitor)
>         at java.lang.Object.wait(Native Method)
>         - waiting on <627e4968> (a java.lang.Thread)
>         at java.lang.Thread.join(Thread.java:1186)
>         - locked <627e4968> (a java.lang.Thread)
>         at java.lang.Thread.join(Thread.java:1239)
>         at org.apache.commons.exec.PumpStreamHandler.stop(PumpStreamHandler.java:171)
>         at org.apache.commons.exec.DefaultExecutor.executeInternal(DefaultExecutor.java:363)
>         at org.apache.commons.exec.DefaultExecutor.execute(DefaultExecutor.java:160)
>         at org.apache.commons.exec.DefaultExecutor.execute(DefaultExecutor.java:147)
> I added timeout to join() and call interrupt() but that doesnt help to kill pump threads. Fortunately, these are daemon threads that do not block JVM from exiting. Except from extra daemon threads this solved problem on linux. But that wasnt able to prevent all hangs on HP-UX. Check following stack
> "main" prio=10 tid=00465600 nid=1 lwp_id=-1 runnable [7fffd000]
>    java.lang.Thread.State: RUNNABLE
>         at java.io.FileInputStream.close0(Native Method)
>         at java.io.FileInputStream.close(FileInputStream.java:259)
>         at java.lang.UNIXProcess$DeferredCloseInputStream.close(UNIXProcess.java:298)
>         at java.io.BufferedInputStream.close(BufferedInputStream.java:451)
>         at org.apache.commons.exec.DefaultExecutor.closeStreams(DefaultExecutor.java:281)
>         at org.apache.commons.exec.DefaultExecutor.executeInternal(DefaultExecutor.java:364)
>         at org.apache.commons.exec.DefaultExecutor.execute(DefaultExecutor.java:160)
>         at org.apache.commons.exec.DefaultExecutor.execute(DefaultExecutor.java:147)
>         at org.apache.commons.exec.DefaultExecutorTest.testSyncInvocationOfBackgroundProcess(DefaultExecutorTest.java:812)
> I dont have idea how this can be interrupted or timed out except that skip closing streams. But in this case we'll probably leak resources.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

       
Reply | Threaded
Open this post in threaded view
|

[jira] [Resolved] (EXEC-57) DefaultExecutor.execute() does not return even if child process terminated

Gilles (Jira)
In reply to this post by Gilles (Jira)

     [ https://issues.apache.org/jira/browse/EXEC-57?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Siegfried Goeschl resolved EXEC-57.
-----------------------------------

    Resolution: Fixed

Applied the patch from Nickolay Martinov but the timeout disguises the fact that the process might be still runnung - therefore added a sanity check in order to throw an exception if the the timeout for join() was exceeded.

               

> DefaultExecutor.execute() does not return even if child process terminated
> --------------------------------------------------------------------------
>
>                 Key: EXEC-57
>                 URL: https://issues.apache.org/jira/browse/EXEC-57
>             Project: Commons Exec
>          Issue Type: Bug
>    Affects Versions: 1.1
>         Environment: > uname -smr
> HP-UX B.11.23 ia64
> $ uname -smr
> Linux 2.6.18-194.3.1.el5xen x86_64
>            Reporter: Nickolay Martinov
>            Assignee: Siegfried Goeschl
>         Attachments: EXEC-57.test.patch
>
>
> When script that starts background process is synchronously executed via DefaultExecutor.execute() then method never returns (until child process spawned by child process terminates).
> Here is example if such script:
> echo "Going to start daemon process"
> sleep 1
> cd ./target
> nohup sleep 10 &
> sleep 1
> echo "Daemon process was started"
> Stream handler is used to grab and print output of script. As can be seen from stack trace problem lies in pump threads that call InputStream.read() that does not return when script that we invoke terminates. Instead it returns only once process started by script terminates.
> "Thread-3" daemon prio=10 tid=00c73a00 nid=17 lwp_id=2640638 runnable [2e180000]
>    java.lang.Thread.State: RUNNABLE
>         at java.io.FileInputStream.readBytes(Native Method)
>         at java.io.FileInputStream.read(FileInputStream.java:177)
>         at java.lang.UNIXProcess$DeferredCloseInputStream.read(UNIXProcess.java:313)
>         at org.apache.commons.exec.StreamPumper.run(StreamPumper.java:105)
>         at java.lang.Thread.run(Thread.java:662)
>    Locked ownable synchronizers:
>         - None
> "Thread-2" daemon prio=10 tid=005fd000 nid=16 lwp_id=2640637 runnable [2e240000]
>    java.lang.Thread.State: RUNNABLE
>         at java.io.FileInputStream.readBytes(Native Method)
>         at java.io.FileInputStream.read(FileInputStream.java:199)
>         at java.lang.UNIXProcess$DeferredCloseInputStream.read(UNIXProcess.java:322)
>         at java.io.BufferedInputStream.fill(BufferedInputStream.java:218)
>         at java.io.BufferedInputStream.read1(BufferedInputStream.java:258)
>         at java.io.BufferedInputStream.read(BufferedInputStream.java:317)
>         - locked <628b1970> (a java.io.BufferedInputStream)
>         at java.io.FilterInputStream.read(FilterInputStream.java:90)
>         at org.apache.commons.exec.StreamPumper.run(StreamPumper.java:105)
>         at java.lang.Thread.run(Thread.java:662)
>    Locked ownable synchronizers:
>         - None
> "main" prio=10 tid=0046aa00 nid=1 lwp_id=-1 in Object.wait() [7fff8000]
>    java.lang.Thread.State: WAITING (on object monitor)
>         at java.lang.Object.wait(Native Method)
>         - waiting on <627e4968> (a java.lang.Thread)
>         at java.lang.Thread.join(Thread.java:1186)
>         - locked <627e4968> (a java.lang.Thread)
>         at java.lang.Thread.join(Thread.java:1239)
>         at org.apache.commons.exec.PumpStreamHandler.stop(PumpStreamHandler.java:171)
>         at org.apache.commons.exec.DefaultExecutor.executeInternal(DefaultExecutor.java:363)
>         at org.apache.commons.exec.DefaultExecutor.execute(DefaultExecutor.java:160)
>         at org.apache.commons.exec.DefaultExecutor.execute(DefaultExecutor.java:147)
> I added timeout to join() and call interrupt() but that doesnt help to kill pump threads. Fortunately, these are daemon threads that do not block JVM from exiting. Except from extra daemon threads this solved problem on linux. But that wasnt able to prevent all hangs on HP-UX. Check following stack
> "main" prio=10 tid=00465600 nid=1 lwp_id=-1 runnable [7fffd000]
>    java.lang.Thread.State: RUNNABLE
>         at java.io.FileInputStream.close0(Native Method)
>         at java.io.FileInputStream.close(FileInputStream.java:259)
>         at java.lang.UNIXProcess$DeferredCloseInputStream.close(UNIXProcess.java:298)
>         at java.io.BufferedInputStream.close(BufferedInputStream.java:451)
>         at org.apache.commons.exec.DefaultExecutor.closeStreams(DefaultExecutor.java:281)
>         at org.apache.commons.exec.DefaultExecutor.executeInternal(DefaultExecutor.java:364)
>         at org.apache.commons.exec.DefaultExecutor.execute(DefaultExecutor.java:160)
>         at org.apache.commons.exec.DefaultExecutor.execute(DefaultExecutor.java:147)
>         at org.apache.commons.exec.DefaultExecutorTest.testSyncInvocationOfBackgroundProcess(DefaultExecutorTest.java:812)
> I dont have idea how this can be interrupted or timed out except that skip closing streams. But in this case we'll probably leak resources.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

       
Reply | Threaded
Open this post in threaded view
|

[jira] [Closed] (EXEC-57) DefaultExecutor.execute() does not return even if child process terminated

Gilles (Jira)
In reply to this post by Gilles (Jira)

     [ https://issues.apache.org/jira/browse/EXEC-57?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Siegfried Goeschl closed EXEC-57.
---------------------------------


Patch applied at 2011-10-10
               

> DefaultExecutor.execute() does not return even if child process terminated
> --------------------------------------------------------------------------
>
>                 Key: EXEC-57
>                 URL: https://issues.apache.org/jira/browse/EXEC-57
>             Project: Commons Exec
>          Issue Type: Bug
>    Affects Versions: 1.1
>         Environment: > uname -smr
> HP-UX B.11.23 ia64
> $ uname -smr
> Linux 2.6.18-194.3.1.el5xen x86_64
>            Reporter: Nickolay Martinov
>            Assignee: Siegfried Goeschl
>         Attachments: EXEC-57.test.patch
>
>
> When script that starts background process is synchronously executed via DefaultExecutor.execute() then method never returns (until child process spawned by child process terminates).
> Here is example if such script:
> echo "Going to start daemon process"
> sleep 1
> cd ./target
> nohup sleep 10 &
> sleep 1
> echo "Daemon process was started"
> Stream handler is used to grab and print output of script. As can be seen from stack trace problem lies in pump threads that call InputStream.read() that does not return when script that we invoke terminates. Instead it returns only once process started by script terminates.
> "Thread-3" daemon prio=10 tid=00c73a00 nid=17 lwp_id=2640638 runnable [2e180000]
>    java.lang.Thread.State: RUNNABLE
>         at java.io.FileInputStream.readBytes(Native Method)
>         at java.io.FileInputStream.read(FileInputStream.java:177)
>         at java.lang.UNIXProcess$DeferredCloseInputStream.read(UNIXProcess.java:313)
>         at org.apache.commons.exec.StreamPumper.run(StreamPumper.java:105)
>         at java.lang.Thread.run(Thread.java:662)
>    Locked ownable synchronizers:
>         - None
> "Thread-2" daemon prio=10 tid=005fd000 nid=16 lwp_id=2640637 runnable [2e240000]
>    java.lang.Thread.State: RUNNABLE
>         at java.io.FileInputStream.readBytes(Native Method)
>         at java.io.FileInputStream.read(FileInputStream.java:199)
>         at java.lang.UNIXProcess$DeferredCloseInputStream.read(UNIXProcess.java:322)
>         at java.io.BufferedInputStream.fill(BufferedInputStream.java:218)
>         at java.io.BufferedInputStream.read1(BufferedInputStream.java:258)
>         at java.io.BufferedInputStream.read(BufferedInputStream.java:317)
>         - locked <628b1970> (a java.io.BufferedInputStream)
>         at java.io.FilterInputStream.read(FilterInputStream.java:90)
>         at org.apache.commons.exec.StreamPumper.run(StreamPumper.java:105)
>         at java.lang.Thread.run(Thread.java:662)
>    Locked ownable synchronizers:
>         - None
> "main" prio=10 tid=0046aa00 nid=1 lwp_id=-1 in Object.wait() [7fff8000]
>    java.lang.Thread.State: WAITING (on object monitor)
>         at java.lang.Object.wait(Native Method)
>         - waiting on <627e4968> (a java.lang.Thread)
>         at java.lang.Thread.join(Thread.java:1186)
>         - locked <627e4968> (a java.lang.Thread)
>         at java.lang.Thread.join(Thread.java:1239)
>         at org.apache.commons.exec.PumpStreamHandler.stop(PumpStreamHandler.java:171)
>         at org.apache.commons.exec.DefaultExecutor.executeInternal(DefaultExecutor.java:363)
>         at org.apache.commons.exec.DefaultExecutor.execute(DefaultExecutor.java:160)
>         at org.apache.commons.exec.DefaultExecutor.execute(DefaultExecutor.java:147)
> I added timeout to join() and call interrupt() but that doesnt help to kill pump threads. Fortunately, these are daemon threads that do not block JVM from exiting. Except from extra daemon threads this solved problem on linux. But that wasnt able to prevent all hangs on HP-UX. Check following stack
> "main" prio=10 tid=00465600 nid=1 lwp_id=-1 runnable [7fffd000]
>    java.lang.Thread.State: RUNNABLE
>         at java.io.FileInputStream.close0(Native Method)
>         at java.io.FileInputStream.close(FileInputStream.java:259)
>         at java.lang.UNIXProcess$DeferredCloseInputStream.close(UNIXProcess.java:298)
>         at java.io.BufferedInputStream.close(BufferedInputStream.java:451)
>         at org.apache.commons.exec.DefaultExecutor.closeStreams(DefaultExecutor.java:281)
>         at org.apache.commons.exec.DefaultExecutor.executeInternal(DefaultExecutor.java:364)
>         at org.apache.commons.exec.DefaultExecutor.execute(DefaultExecutor.java:160)
>         at org.apache.commons.exec.DefaultExecutor.execute(DefaultExecutor.java:147)
>         at org.apache.commons.exec.DefaultExecutorTest.testSyncInvocationOfBackgroundProcess(DefaultExecutorTest.java:812)
> I dont have idea how this can be interrupted or timed out except that skip closing streams. But in this case we'll probably leak resources.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira