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

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


            }
            
            // Construct the result.
            let executionResult = ProcessResult(
                arguments: arguments,
                exitStatus: exitStatus,
                output: stdout.result
            )
            self._result = executionResult
            return executionResult
        }
    }

    /// Reads the given fd and returns its result.
    ///
    /// Closes the fd before returning.
    private func readOutput(onFD fd: Int32) -> Result<[Int8], AnyError> {
        // Read all of the data from the output pipe.
        let N = 4096
        var buf = [Int8](repeating: 0, count: N + 1)
