q/examples/shell/shell.q
2025-04-15 09:31:49 +02:00

27 lines
340 B
Plaintext

import io
import mem
import sys
main() {
length := 256
command := mem.alloc(length)
loop {
io.write("λ ")
n := io.read(command)
if n <= 0 {
return
}
command[n-1] = 0
pid := sys.clone(sig.chld, 0, 0, 0, 0)
if pid == 0 {
sys.execve(command, 0, 0)
return
}
sys.waitid(idtype.pid, pid, 0, state.exited)
}
}