diff --git a/examples/shell/shell.q b/examples/shell/shell.q index 3353391..509b53e 100644 --- a/examples/shell/shell.q +++ b/examples/shell/shell.q @@ -2,29 +2,35 @@ import io import mem import sys +const idtype { + pid 1 +} + +const state { + exited 0x4 +} + main() { length := 256 command := mem.alloc(length) - argv := mem.alloc(1) - envp := mem.alloc(1) - info := mem.alloc(24) + siginfo := mem.alloc(128) loop { - io.out("$ ") + io.out("λ ") n := io.in(command) if n <= 0 { return } - command[n-1] = '\0' + command[n-1] = 0 pid := sys.fork() if pid == 0 { - sys.execve(command, argv, envp) + sys.execve(command, 0, 0) return } - sys.waitid(0, pid, info, 4) + sys.waitid(idtype.pid, pid, siginfo, state.exited) } } \ No newline at end of file