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

File descriptor leak with ProcessBuilder.startPipeline

XMLWordPrintable

    • b08
    • x86_64
    • linux
    • Verified

        ADDITIONAL SYSTEM INFORMATION :
        Ubuntu 21.10 / Debian GNU/Linux 10 (buster)
        Java: 17.0.3/11.0.15

        A DESCRIPTION OF THE PROBLEM :
        When using ProcessBuilder.startPipeline the pipes (or pipe if only 2 ProcessBuilder instance used) created are never closed.

        EXPECTED VERSUS ACTUAL BEHAVIOR :
        EXPECTED -
        the pipes created by ProcessBuilder.startPipeline are closed
        ACTUAL -
        the pipes created by ProcessBuilder.startPipeline are never closed

        ---------- BEGIN SOURCE ----------
        List<ProcessBuilder> processBuilders = new LinkedList<>();
        processBuilders.add(new ProcessBuilder("ls"));
        processBuilders.add(new ProcessBuilder("grep", "a"));
        List<Process> processes = ProcessBuilder.startPipeline(processBuilders);
        Process last = processes.get(processes.size()-1);
        last.waitFor();

        try (InputStream inputStream = last.getInputStream()) {
            inputStream.readAllBytes();
        }
        ---------- END SOURCE ----------

        FREQUENCY : always


              rriggs Roger Riggs
              webbuggrp Webbug Group
              Votes:
              0 Vote for this issue
              Watchers:
              9 Start watching this issue

                Created:
                Updated:
                Resolved: