Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4482614

LINUX: process reaping is broken

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 1.3.1_09
    • 1.4.0
    • hotspot
    • None
    • 09
    • generic
    • linux

        The following test program creates 10 threads, each thread then executes
        1000 times "/bin/ls". It can run successfully on Solaris but will
        hang on Linux with JDK 1.3.1 or 1.4-beta.

        -----------------------------------------------------------------------
        public class ExecTest
        {
            public static void main(String[] argv)
            {
                for (int i = 1; i < 10; i++) {
                    final int ii = i;
                    new Thread() {
                        public void run()
                        {
                            ExecTest c = new ExecTest(ii);
                        }
                    }.start();
                }
            }

            ExecTest(int i)
            {
                doExecs(i);
            }

            private void doExecs(int ii)
            {
                int i = 0;
                while (true) {
                    try {
                        Runtime rt = Runtime.getRuntime();
                        Process p = rt.exec("/bin/ls");
                        p.waitFor();
                        System.err.println("Thread " + ii + " created " +
                                           ++i + " processes so far");
                        if (i >= 1000) {
                            System.err.println("Thread " + ii + "finished.");
                            break;
                        }
                    } catch (Exception e) {
                        System.out.println(e.getMessage());
                        e.printStackTrace();
                        System.exit(1);
                    }
                }
            }
        }
        ------------------------------------------------------------------------

              hhuangsunw Hui Huang (Inactive)
              hhuangsunw Hui Huang (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: