Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions userland/apps/shell/src/line_edit.c
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,18 @@ char* line_edit_read(line_edit_state* s, const char* prompt) {
continue;
}

if (c == 0x03) { // Ctrl-C: discard the line, start fresh
s->cursor_pos = s->line_len;
redraw(s, prompt); /* park the cursor at end of line */
write(1, "^C\r\n", 4);
s->line_buf[0] = '\0';
s->line_len = 0;
s->cursor_pos = 0;
s->history_index = s->history_count < HISTORY_MAX ? s->history_count : HISTORY_MAX;
write_str(prompt);
continue;
}

if (c == '\r' || c == '\n') {
write(1, "\r\n", 2);
s->line_buf[s->line_len] = '\0';
Expand Down
10 changes: 8 additions & 2 deletions userland/apps/shell/src/shell.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,21 @@ static int reap_status(int status) {
int sig = STLX_WTERMSIG(status);
const char* name;
switch (sig) {
case 2: /* SIGINT: the terminal's ^C echo already told the story */
case 13: /* SIGPIPE: routine death for pipeline members */
name = NULL; break;
case 4: name = "Illegal instruction"; break;
case 7: name = "Bus error"; break;
case 8: name = "Floating point exception"; break;
case 9: name = "Killed"; break;
case 11: name = "Segmentation fault"; break;
case 15: name = "Terminated"; break;
default: name = "Terminated by signal"; break;
}
shell_err(name);
shell_err("\r\n");
if (name) {
shell_err(name);
shell_err("\r\n");
}
return 128 + sig;
}
return status;
Expand Down
Loading