Files
bun-src/docs/guides/process/spawn-stdout.mdx
T

29 lines
596 B
Plaintext
Raw Normal View History

2026-08-27 21:09:14 +00:00
---
title: Read stdout from a child process
sidebarTitle: Read stdout
mode: center
---
When you spawn a child process with [`Bun.spawn()`](/runtime/child-process), `proc.stdout` is a `ReadableStream` of the child's `stdout`.
```ts
const proc = Bun.spawn(["echo", "hello"]);
const output = await proc.stdout.text();
output; // => "hello\n"
```
---
To pipe the child process's `stdout` to the parent's `stdout` instead, set the `stdout` option to `"inherit"`.
```ts
const proc = Bun.spawn(["echo", "hello"], {
stdout: "inherit",
});
```
---
See [Child processes](/runtime/child-process).