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

java.lang.Process is unresponsive and CPU usage spikes to 100%

XMLWordPrintable

    • b01
    • b24
    • generic
    • os_x

        ADDITIONAL SYSTEM INFORMATION :
        A DESCRIPTION OF THE PROBLEM :
        In JDK 8, using the Process class to execute the command "/Applications/LibreOffice.app/Contents/MacOS/soffice --help"works as expected. However, after switching to JDK 21, the thread executing the command becomes unresponsive, and the forked process causes CPU usage to spike to 100%.

        STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
        1. install soffice
        2. run code
        3. switch jdk

        EXPECTED VERSUS ACTUAL BEHAVIOR :
        EXPECTED -
        return immediately
        ACTUAL -
        no result

        ---------- BEGIN SOURCE ----------
                    ProcessBuilder processBuilder = new ProcessBuilder(
                            "/Applications/LibreOffice.app/Contents/MacOS/soffice",
                            "--help"
                    );

                    Process process = processBuilder.start();

                    BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
                    String line;
                    while ((line = reader.readLine()) != null) {
                        System.out.println(line);
                    }

                    int exitCode = process.waitFor();
                    System.out.println("Process exited with code: " + exitCode);
        ---------- END SOURCE ----------

              gziemski Gerard Ziemski
              webbuggrp Webbug Group
              Votes:
              1 Vote for this issue
              Watchers:
              12 Start watching this issue

                Created:
                Updated:
                Resolved: