Repository navigation
Child Processes
Chris Michael edited this page Oct 7, 2026
·
1 revision
A child process inherits the process environment, which does not hold the loaded values. Variables.apply gives a Std.Process launch every key the load applied:
module Ex07Child
import Std.Io as Io
import Std.Process as Process
import PuduLangEnvironment.Loader as Loader
import PuduLangEnvironment.Options as Options
import PuduLangEnvironment.Source as Source
import PuduLangEnvironment.Variables as Variables
export fn main() -> Int {
let options = Options.defaults().withSources(&[Source.Text("example", "GREETING=hello\nTARGET=world\n")])
match Loader.load(&options) {
case Ok(variables) => {
let plan = Variables.apply(&variables, &Process.launch("sh", &["-c", "echo \"$GREETING, $TARGET\""]).isolated())
match Process.runLaunch(&plan, "") {
case Ok(finished) => {
let _shown = Io.writeLine(finished.output.trim())
0
}
case Err(_) => 1
}
}
case Err(_) => 1
}
}
Output:
hello, world
isolated() keeps the rest of the program's environment from the child; without it the child inherits the process environment and receives the applied keys over it.