# child_process
[](https://hex.pm/packages/child_process)
[](https://hexdocs.pm/child_process/)
A cross-platform library for spawning child processes in Gleam, inspired by Rust's `std::process` module.
Run shell commands, execute binaries with full control over stdio, or even launch interactive programs like vim directly from your Gleam code.
```sh
gleam add child_process@1
```
## Features
- **Cross-platform**: Works on both Erlang and JavaScript (Node.js) targets
- **Flexible I/O**: Capture output, inherit stdio for interactive programs, or stream lines with callbacks
- **Process control**: Write to stdin, stop gracefully, or kill processes
- **Builder API**: Clean, chainable interface for configuring processes
## Usage
### Run a shell command
```gleam
import child_process
let assert Ok(output) = child_process.shell("echo Hello, World!")
io.println(output)
```
### Launch interactive programs
```gleam
import child_process
import child_process/stdio
// Run vim interactively - stdio is inherited so you can use it normally!
child_process.new("vim")
|> child_process.arg("README.md")
|> child_process.stdio(stdio.inherit())
|> child_process.run()
```
### Stream output line-by-line
```gleam
import child_process
import child_process/stdio
// Watch mode with live output
child_process.new("tailwindcss")
|> child_process.args(["-i", "input.css", "-o", "output.css", "--watch"])
|> child_process.stdio(stdio.lines(fn(line) {
io.println(line)
}))
|> child_process.spawn()
```
Further documentation can be found at <https://hexdocs.pm/child_process>.