diff --git a/userspace/Shell/main.cpp b/userspace/Shell/main.cpp index d40fe5f4..7e890a47 100644 --- a/userspace/Shell/main.cpp +++ b/userspace/Shell/main.cpp @@ -380,10 +380,16 @@ int execute_command(BAN::Vector& args) if (pid == -1) ERROR_RETURN("fork", 1); + if (tcsetpgrp(0, pid) == -1) + ERROR_RETURN("tcsetpgrp", 1); + int status; if (waitpid(pid, &status, 0) == -1) ERROR_RETURN("waitpid", 1); + if (tcsetpgrp(0, getpid()) == -1) + ERROR_RETURN("tcsetpgrp", 1); + return status; } @@ -489,6 +495,9 @@ int main(int argc, char** argv) { argv0 = argv[0]; + if (signal(SIGINT, [](int) {}) == SIG_ERR) + perror("signal"); + if (argc >= 2) { if (strcmp(argv[1], "-c") == 0) @@ -599,6 +608,12 @@ int main(int argc, char** argv) fflush(stdout); } break; + case '\x03': // ^C + fputc('\n', stdout); + print_prompt(); + buffers[index].clear(); + col = 0; + break; case '\n': fputc('\n', stdout); if (!buffers[index].empty()) diff --git a/userspace/init/main.cpp b/userspace/init/main.cpp index ef0372d2..b0991796 100644 --- a/userspace/init/main.cpp +++ b/userspace/init/main.cpp @@ -22,6 +22,9 @@ int main() { initialize_stdio(); + if (signal(SIGINT, [](int) {}) == SIG_ERR) + perror("signal"); + bool first = true; while (true) @@ -85,9 +88,15 @@ int main() perror("fork"); break; } - + + if (tcsetpgrp(0, pid) == -1) + perror("tcsetpgrp"); + int status; waitpid(pid, &status, 0); + + if (tcsetpgrp(0, getpid()) == -1) + perror("tcsetpgrp"); } }