> ## Documentation Index
> Fetch the complete documentation index at: https://bun.zhcndoc.com/llms.txt
> Use this file to discover all available pages before exploring further.

# 从子进程读取标准输出

使用 [`Bun.spawn()`](/runtime/child-process) 时，可以通过 `proc.stdout` 将子进程的标准输出作为 `ReadableStream` 来消费。

```ts theme={"theme":{"light":"github-light","dark":"dracula"}}
const proc = Bun.spawn(["echo", "hello"]);

const output = await proc.stdout.text();
output; // => "hello"
```

***

如果想将子进程的标准输出直接重定向到父进程的标准输出，可以设置为 "inherit"。

```ts theme={"theme":{"light":"github-light","dark":"dracula"}}
const proc = Bun.spawn(["echo", "hello"], {
  stdout: "inherit",
});
```

***

完整文档请参见 [文档 > API > 子进程](/runtime/child-process)。
