这是indexloc提供的服务,不要输入任何密码
Skip to content

Spawning a process #3325

@HumanEntity

Description

@HumanEntity

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:

package main

import "core:process"
import "core:fmt"

main :: proc () {
    process_handle, process_spawn_err := process.spawn({"echo", "'Hello, World"})
    if process_spawn_err != nil {
        fmt.panicf("Failed to start command: %v", process_spawn_err)
    }
    output := process.output(process_handle)
    fmt.println(output)
}

Solution in Rust

use std::process::Command;

let output = Command::new("echo")
    .arg("Hello world")
    .output()
    .expect("Failed to start command")
println!("{output}")

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions