exec resource leak

General
Anonymous
2012-03-27
2013-05-28
  • Anonymous - 2012-03-27

    Every <exec> I do opens 3 file descriptors and never closes them.  I've verified that the child processes run, complete, and reap as expected (no zombies or hung processes).  A simple example to reproduce this follows.  I just run this and then watch with lsof as the file descriptors pile up.  I'm using oddjob 1.1.0 on both linux (Java 1.6.0_24) and osx (Java 1.6.0_29).

    <oddjob id="exec_monster">
        <job>
            <sequential name="main" id="root">
                <jobs>
                    <exec>sleep 5</exec>
                    <exec>sleep 5</exec>
                    <exec>sleep 5</exec>
                    <exec>sleep 5</exec>
                    <exec>sleep 5</exec>
                    <exec>sleep 5</exec>
                    <exec>sleep 5</exec>
                    <exec>sleep 5</exec>
                    <exec>sleep 5</exec>
                    <exec>sleep 5</exec>
                    <exec>sleep 5</exec>
                    <exec>sleep 5</exec>
                </jobs>
            </sequential>
        </job>
    </oddjob>

     
  • Anonymous - 2012-03-27

    I believe I've cured this behavior with the following patch.  Haven't tested it much, but initial results look good.

    --- ./oddjob/src/java/org/oddjob/jobs/ExecJob.java.ORIG 2012-03-27 16:21:28.941347109 -0400
    +++ ./oddjob/src/java/org/oddjob/jobs/ExecJob.java  2012-03-27 15:50:43.511347239 -0400
    @@ -444,6 +444,9 @@
            }
            finally {
                thread = null;
    +           proc.getInputStream().close();
    +           proc.getOutputStream().close();
    +           proc.getErrorStream().close();
                synchronized (this) {
                    // wake up the stop wait.
                    notifyAll();
    
     
  • Rob Gordon

    Rob Gordon - 2012-03-28

    Googling agrees with your findings. I've applied your patch and added an extra process.destroy() as per the advice of this blog: http://kylecartmell.com/?p=9

    Thanks for this,
    Rob.

     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks