host: process table, shell, coreutils and harness (T8, T9)
T8: sausage:process WIT (spawn, wait, kill), one store per process over the shared root, /proc/processes, /run, pipeline and cancellation groups, Exec. brush and 78 uutils commands; the shared cwd-init object sets the cwd from PWD and keeps numeric exit codes. The corpus matches native bash. T9: V8 (deno_core) runs pi-durable, pi-ai and chord; SQLite storage in <dir>/host/harness.sqlite (WAL, synchronous=FULL); file tools on the VFS, bash through Exec; resumes after SIGKILL.
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
//! ps reads the process snapshot. kill stops a process group through the process interface.
|
||||
mod bindings {
|
||||
wit_bindgen::generate!({ path: "../../host/wit", world: "program", generate_all });
|
||||
}
|
||||
fn main() {
|
||||
let args: Vec<String> = std::env::args().collect();
|
||||
match std::path::Path::new(&args[0])
|
||||
.file_name()
|
||||
.unwrap()
|
||||
.to_str()
|
||||
.unwrap()
|
||||
{
|
||||
"ps" => print!(
|
||||
"{}",
|
||||
std::fs::read_to_string("/proc/processes").expect("process snapshot")
|
||||
),
|
||||
"kill" => {
|
||||
if args.len() < 2 {
|
||||
std::process::exit(2);
|
||||
}
|
||||
for pid in &args[1..] {
|
||||
let pid: u32 = pid.parse().expect("numeric pid");
|
||||
if let Err(error) = bindings::sausage::process::host::kill(pid) {
|
||||
eprintln!("kill: {error}");
|
||||
std::process::exit(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
_ => std::process::exit(127),
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user