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, cmd_err := sp.command_make("cc") // Will search from PATH
// File paths are also valid
// prog := sp.command_make("./bin/cc")
if cmd_err != nil {return}
defer sp.command_destroy(&cmd)
sp.command_append(&cmd, "--version")
result, result_err := sp.command_run(cmd, sp.Exec_Opts{output = .Capture})
if result_err != nil {return}
defer sp.result_destroy(&result)
sp.log_info("Output:", string(result.stdout))
}
// See more examples in demos/examples.odin
- 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.