diff options
author | Alex Auvolat <alex@adnab.me> | 2015-03-13 15:37:30 +0100 |
---|---|---|
committer | Alex Auvolat <alex@adnab.me> | 2015-03-13 15:37:30 +0100 |
commit | 41a4f5309ef298da764bf1dca1254e734a4417f0 (patch) | |
tree | 43e2e820f39c09db36d3a12e3fb2495cb38adca7 /src/sysbin/login/main.c | |
parent | d0dc9f38184956af49379d7e2585756523cfa4c1 (diff) | |
download | kogata-41a4f5309ef298da764bf1dca1254e734a4417f0.tar.gz kogata-41a4f5309ef298da764bf1dca1254e734a4417f0.zip |
Basis for a shell.
Diffstat (limited to 'src/sysbin/login/main.c')
-rw-r--r-- | src/sysbin/login/main.c | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/src/sysbin/login/main.c b/src/sysbin/login/main.c index 5d8840b..359d677 100644 --- a/src/sysbin/login/main.c +++ b/src/sysbin/login/main.c @@ -8,6 +8,9 @@ int main(int argc, char **argv) { dbg_print("[login] Starting up.\n"); + // communication channel between terminal && shell + fd_pair_t tc = make_channel(false); + // just launch a terminal pid_t term_pid = new_proc(); if (term_pid == 0) { @@ -16,17 +19,32 @@ int main(int argc, char **argv) { bool ok; - ok = bind_fs(term_pid, "root", "root") - && bind_fs(term_pid, "sys", "sys") + ok = bind_fs(term_pid, "sys", "sys") && bind_fs(term_pid, "config", "config") - && bind_fd(term_pid, 1, 1); + && bind_fd(term_pid, 1, 1) + && bind_fd(term_pid, 2, tc.a); if (!ok) PANIC("[login] Could not bind to terminal process."); ok = proc_exec(term_pid, "sys:/bin/terminal.bin"); if (!ok) PANIC("[login] Could not run terminal.bin"); + // and launch the shell + pid_t shell_pid = new_proc(); + if (shell_pid == 0) { + PANIC("[login] Could not launch shell"); + } + + ok = bind_fs(shell_pid, "root", "root") + && bind_fs(shell_pid, "sys", "sys") + && bind_fs(shell_pid, "config", "config") + && bind_fd(shell_pid, 1, tc.b); + if (!ok) PANIC("[login] Could not bind to shell process."); + + ok = proc_exec(shell_pid, "sys:/bin/shell.bin"); + if (!ok) PANIC("[login] Could not run shell.bin"); + proc_status_t s; - proc_wait(term_pid, true, &s); + proc_wait(0, true, &s); return 0; } |