diff options
author | dzwdz | 2022-08-29 21:58:15 +0200 |
---|---|---|
committer | dzwdz | 2022-08-29 21:58:15 +0200 |
commit | 69d7da4945448f4a6901b085e746e977359f465c (patch) | |
tree | e27ca90240094a71afc29d17273e66c7096dac96 /src/user/app/init/driver | |
parent | 383b08ae41f5d038719c50def311fa2d56c4fb79 (diff) |
user/termcook: make C-c kill the running process
Diffstat (limited to 'src/user/app/init/driver')
-rw-r--r-- | src/user/app/init/driver/termcook.c | 15 |
1 files changed, 11 insertions, 4 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()); } |