             }
             // Create a thread and start reading the output on it.
             let thread = Thread {
-                self.readOutput(onFD: outputPipe[0])
+                self.stdout.result = self.readOutput(onFD: outputPipe[0])
             }
             thread.start()
-            readOutputThread = thread
+            self.stdout.thread = thread
         }
     }
 

    /// The result of the process execution. Available after process is terminated.
    private var _result: ProcessResult?
    
    /// The thread to read the output from the process, if redirected.
    private var readOutputThread: Thread? = nil

    /// Error encountered during reading of redirected output.
    private var readOutputError: Swift.Error? = nil

    /// The output read from the process, if redirected.
    private var output: [Int8] = []
    
    /// Queue to protect concurrent reads.
    private let serialQueue = DispatchQueue(label: "org.swift.swiftpm.process")

            }
        
            // If we're reading output, make sure that is finished.
            if let thread = stdout.thread {
                assert(redirectOutput)
                thread.join()
            }
