This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug java/14709] New: gcj fails to wait for its child processes on exec()


[forwarded from http://bugs.debian.org/238432]

When calling Runtime.getRuntime.exec(String) in program that has been
compiled with gcj-3.3.3, process is created and works as expected, but
process is not reaped. With Sun JVM 1.5.0-beta the same programs work
fine.

We tested this also with gcc-3.4 CVS 20040314-1, with same results.

Steps to reproduce:
1) Write a program that calls Runtime.getRuntime.exec("uptime"),
opens and closes both input and output stream and calls destroy()
to process (or use the one I attach when this report hits the web)
and that continues to run.
2) See process listing: the processes created by exec() show there
as <defunct>.

import java.io.*;

/**
 * This program demonstrates bug in gcj Runtime.exec().
 *
 * @author Jari Juslin, zds@iki.fi
 *
 * @version $Revision$
 */

public class GcjExecBugDemo {
    
/* **************************************************************** */
                    
    void run() {
        Process uptimeProcess;
        Reader  stdoutReader;
        
        while (true) {
            try {
                uptimeProcess = Runtime.getRuntime().exec("uptime");
                // Just to make sure that bug is not in not opening
                // input to process.
                uptimeProcess.getOutputStream().close();
                stdoutReader = new
InputStreamReader(uptimeProcess.getInputStream());
                
                while (stdoutReader.read() != -1)
                    ;
                stdoutReader.close();
                uptimeProcess.destroy();
    
                try {
                    Thread.sleep(100);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            } catch (IOException e) {
                System.out.println("IOException: " +
                    e.getMessage());
    
                try {
                    Thread.sleep(2000);
                } catch (InterruptedException ex) {
                    ex.printStackTrace();
                }
            }
        }
    }
    
/* **************************************************************** */
                
    public static void main(String[] args) {
        GcjExecBugDemo  gcjExecBugDemo;
        
        gcjExecBugDemo = new GcjExecBugDemo();
        gcjExecBugDemo.run();
    }
}

-- 
           Summary: gcj fails to wait for its child processes on exec()
           Product: gcc
           Version: 3.3.4
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: java
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: debian-gcc at lists dot debian dot org
                CC: gcc-bugs at gcc dot gnu dot org,java-prs at gcc dot gnu
                    dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14709


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]