pub async fn spawn(script: &str, options: ScriptOptions) -> Result<SpawnResult>Expand description
Spawn an OpenScript process from a string without waiting for completion.
This function creates a temporary file with the script content and spawns
the OpenScript process, returning a Child handle for further interaction.
The returned SpawnResult contains the Child and a handle to the temporary
file, ensuring it is not deleted until the SpawnResult is dropped.
§Arguments
script- The OpenScript code to executeoptions- Configuration options for script execution
§Returns
Returns a SpawnResult that can be used to interact with the running process.
§Examples
use openrunner_rs::{spawn, ScriptOptions};
let options = ScriptOptions::new().openscript_path("/bin/sh");
let spawn_result = spawn("echo 'Background task'", options).await?;
let output = spawn_result.child.wait_with_output().await?;
println!("Output: {}", String::from_utf8_lossy(&output.stdout));