spawn-group.j
use io;
use os;
def p as os.Process init os.spawnWith(
["sh", "-c", "sleep 30 & sleep 30; wait"],
os.SpawnOptions{
cleanEnv: true,
env: {"PATH": "/usr/bin:/bin"},
group: true
});
try {
os.waitTimeout($p, 500);
} catch (e) {
if ($e.kind != "timeout") {
throw $e;
}
io.printf("still running after 500 ms: %s\n", $e.kind);
os.signal($p, "term");
}
def r as os.Result init os.wait($p);
io.printf("exit code %d\n", $r.exitCode);