An Odin library for spawning child processes.
- Cross-platform (POSIX and Windows)
- Capturing output
- Sending input
- Asynchronous/parallel execution
- Command builder
- Checking if program exists
- Running shell commands (System-specific shell)
- Passing environment variables to process
- Clone the repo to your project
- Import the package into your Odin file
See demos/examples.odin
.
package main
import sp "subprocess"
main :: proc() {
cmd, _ := sp.command_make("cc") // Will search from PATH
// File paths are also valid
// prog, _ := sp.command_make("./bin/cc")
defer sp.command_destroy(&cmd)
sp.command_append(&cmd, "--version")
result, _ := sp.command_run(cmd, sp.Exec_Opts{output = .Capture})
defer sp.result_destroy(&result)
sp.log_info("Output:", string(result.stdout))
}
// See more examples in demos/examples.odin
// Tests are also great examples
Warning
The generated documentation is not great. I advise you to look at the source code for documentation.
- Compile
odin-doc
- Clone https://github.com/odin-lang/pkg.odin-lang.org
- Build it:
odin build . -out:odin-doc
Then,
make docs
cd docs/site
python3 -m http.server 10101
- Go to
localhost:10101
Or alternatively,
cd docs
make serve
- Go to
localhost:10101
See changelog.