2025-02-09 14:14:41 +01:00
|
|
|
import io
|
2025-01-20 21:37:23 +01:00
|
|
|
import mem
|
|
|
|
import sys
|
|
|
|
|
2025-02-16 21:30:36 +01:00
|
|
|
const idtype {
|
|
|
|
pid 1
|
|
|
|
}
|
|
|
|
|
|
|
|
const state {
|
|
|
|
exited 0x4
|
|
|
|
}
|
|
|
|
|
2025-01-20 21:37:23 +01:00
|
|
|
main() {
|
|
|
|
length := 256
|
|
|
|
command := mem.alloc(length)
|
|
|
|
|
|
|
|
loop {
|
2025-02-16 21:30:36 +01:00
|
|
|
io.out("λ ")
|
2025-02-09 14:14:41 +01:00
|
|
|
n := io.in(command)
|
2025-01-20 21:37:23 +01:00
|
|
|
|
|
|
|
if n <= 0 {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2025-02-16 21:30:36 +01:00
|
|
|
command[n-1] = 0
|
2025-01-20 21:37:23 +01:00
|
|
|
pid := sys.fork()
|
|
|
|
|
|
|
|
if pid == 0 {
|
2025-02-16 21:30:36 +01:00
|
|
|
sys.execve(command, 0, 0)
|
2025-01-20 21:37:23 +01:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2025-02-17 17:49:42 +01:00
|
|
|
sys.waitid(idtype.pid, pid, 0, state.exited)
|
2025-01-20 21:37:23 +01:00
|
|
|
}
|
|
|
|
}
|