-
-
Notifications
You must be signed in to change notification settings - Fork 758
Spawning a process #3325
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
There is a procedure "process_start" inside core/os/os2/process.odin. But it is not implemented yet or better the whole os2 folder is under construction. |
This is currently being addressed by the following PR: #3310 If I'm not mistaken the code in the PR practically handles the use-case specified, though it requires a tiny bit more work before I can confidently suggest you copying the code for your own usage. |
It would be great to have something similar to go's |
Like @flysand7 said, this is being worked on in the new os package, currently at The example provided here can be done there with the current functionality like so: package main
import os "core:os/os2"
import "core:fmt"
main :: proc() {
if err := echo(); err != nil {
os.print_error(os.stderr, err, "failed to execute echo")
}
}
echo :: proc() -> (err: os.Error) {
r, w := os.pipe() or_return
defer os.close(r)
p: os.Process; {
defer os.close(w)
p = os.process_start({
command = {"echo", "Hello world"},
stdout = w,
}) or_return
}
output := os.read_entire_file(r, context.temp_allocator) or_return
_ = os.process_wait(p) or_return
fmt.print(string(output))
return
} |
Description
I am a odin newbie so I might overlooked something but as a way of learning odin I wanted to make simple build system for odin. And when I was trying to spawn shell process I didn't find anything to do this in
core
.Example solution in Odin
For example something like this:
Solution in Rust
The text was updated successfully, but these errors were encountered: