summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/user/app/init/driver/termcook.c15
-rw-r--r--src/user/app/init/init.c2
2 files changed, 12 insertions, 5 deletions
diff --git a/src/user/app/init/driver/termcook.c b/src/user/app/init/driver/termcook.c
index c23d76f..818f8f9 100644
--- a/src/user/app/init/driver/termcook.c
+++ b/src/user/app/init/driver/termcook.c
@@ -29,6 +29,8 @@ static void line_editor(handle_t input, handle_t output) {
linepos--;
}
break;
+ case 3: /* C-c */
+ _syscall_exit(1);
case 4: /* EOT, C-d */
if (linepos > 0) {
w_output(output, linebuf, linepos);
@@ -62,12 +64,17 @@ void termcook(void) {
return;
if (!fork()) {
+ /* the caller continues in a child process,
+ * so it can be killed when the line editor quits */
+ _syscall_dup(stdin_pipe[0], 0, 0);
+ close(stdin_pipe[0]);
+ close(stdin_pipe[1]);
+ return;
+ }
+ if (!fork()) {
close(stdin_pipe[0]);
line_editor(0, stdin_pipe[1]);
exit(0);
}
- /* 0 is stdin, like in unix */
- _syscall_dup(stdin_pipe[0], 0, 0);
- close(stdin_pipe[0]);
- close(stdin_pipe[1]);
+ exit(_syscall_await());
}
diff --git a/src/user/app/init/init.c b/src/user/app/init/init.c
index 24a0056..b97b483 100644
--- a/src/user/app/init/init.c
+++ b/src/user/app/init/init.c
@@ -18,10 +18,10 @@ void redirect(const char *exe, const char *out, const char *in) {
die("couldn't open %s\n", out);
if (!freopen(in, "r", stdin))
die(" couldn't open %s\n", in);
- termcook();
for (;;) {
if (!fork()) {
+ termcook();
execv(exe, NULL);
fprintf(stderr, "init: couldn't start %s\n", exe);
_syscall_sleep(5000);