Skip to main content

Module process

Module process 

Source
Available on crate features sandbox and process only.
Expand description

ProcessBackend — subprocess-based code execution via tokio::process::Command.

This backend spawns child processes to execute code in various languages. It enforces timeout and environment isolation but does not enforce memory limits, network isolation, or filesystem isolation.

§Supported Languages

LanguageExecution Strategy
RustWrite to temp file → compile with rustc → run binary
PythonWrite to temp file → run with python3
JavaScriptWrite to temp file → run with node
TypeScriptWrite to temp file → run with node (same as JS)
CommandExecute code as sh -c "<code>"
WasmNot supported — use WasmBackend instead

§Example

use adk_sandbox::{ProcessBackend, ExecRequest, Language, SandboxBackend};
use std::time::Duration;
use std::collections::HashMap;

let backend = ProcessBackend::default();
let request = ExecRequest {
    language: Language::Python,
    code: "print('hello')".to_string(),
    stdin: None,
    timeout: Duration::from_secs(30),
    memory_limit_mb: None,
    env: HashMap::new(),
};
let result = backend.execute(request).await?;
assert_eq!(result.stdout.trim(), "hello");

Structs§

ProcessBackend
Subprocess-based sandbox backend.
ProcessConfig
Configuration for ProcessBackend.