Runtime
Bundler
Package Manager
Test Runner
Guides
Reference
Blog
Install Bun
Guides Process & System

Read stdout from a child process

When you spawn a child process with Bun.spawn(), proc.stdout is a ReadableStream of the child's stdout.

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".

const proc = Bun.spawn(["echo", "hello"], {
  stdout: "inherit",
});

See Child processes.

On this page

No Headings