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

(process) Process enhancements for capturing output and handling errors

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Unresolved
    • Icon: P4 P4
    • None
    • None
    • core-libs
    • None

      Process and ProcessBuilder provide a low level interface to process streams and process status.
      Higher level APIs could streamline the reading and writing of the streams and capturing stream output into usable Strings, Lists, or Streams.


      Comments on the existing APIs:

      - Building a pipeline with ProcessBuilder.startPipeline is really good. It would probably be good to have a way to have central handling of stderr, though, say all inherit from the JVM, or all are redirected to the same place.

      - Getting the exit statuses is a bit tricky. It might be safe to have a simplification that reports only the last process's exit status. (Unix shells do this.) Waiting for the last process in the pipeline is usually sufficient, as if it exits, it's a good bet that the previous ones have all exited too. Then again, it might be simple enough for the caller to call getLast() on the list of procs and just operate on it (e.g., reading from its output and calling waitFor).

      - For error reporting purposes it is somewhat inconvenient to have to keep the ProcessBuilder list around. I initially inlined the List.of() passed to startPipeline(). But if there was an error I wanted to report the process name with its exit status. But the process name apparently isn't available from a Process? Its Info seemed empty at this point, possibly because the process has already exited.

            Unassigned Unassigned
            rriggs Roger Riggs
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: