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

    /// 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")

                out += buf[0..<n]
            }
        }
        // Close the read end of the output pipe.
        close(fd)
        // Construct the output result.
        return error.map(Result.init) ?? Result(out)
    }

    /// Send a signal to the process.
