From 759b613015f18eb641d17b3b7be345b05ac2424c Mon Sep 17 00:00:00 2001 From: MikeCAT Date: Thu, 22 Sep 2022 16:41:49 +0000 Subject: [PATCH 1/2] add exit command --- kernel/terminal.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/kernel/terminal.cpp b/kernel/terminal.cpp index 9fdd5d99d..d807960f0 100644 --- a/kernel/terminal.cpp +++ b/kernel/terminal.cpp @@ -483,6 +483,12 @@ void Terminal::ExecuteLine() { {4, 4}, {8*kColumns, 16*kRows}, {0, 0, 0}); } cursor_.y = 0; + } else if (strcmp(command, "exit") == 0) { + if (show_window_) { + CloseLayer(layer_id_); + } + __asm__("cli"); + task_manager->Finish(0); } else if (strcmp(command, "lspci") == 0) { for (int i = 0; i < pci::num_device; ++i) { const auto& dev = pci::devices[i]; From 3519fa1cb2f396340d83d0be835e064f93cea8d9 Mon Sep 17 00:00:00 2001 From: MikeCAT Date: Thu, 22 Sep 2022 16:46:42 +0000 Subject: [PATCH 2/2] add exit code support to exit command --- kernel/terminal.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/kernel/terminal.cpp b/kernel/terminal.cpp index d807960f0..8e410a09c 100644 --- a/kernel/terminal.cpp +++ b/kernel/terminal.cpp @@ -487,8 +487,10 @@ void Terminal::ExecuteLine() { if (show_window_) { CloseLayer(layer_id_); } + int exit_code = 0; + if (first_arg) exit_code = atoi(first_arg); __asm__("cli"); - task_manager->Finish(0); + task_manager->Finish(exit_code); } else if (strcmp(command, "lspci") == 0) { for (int i = 0; i < pci::num_device; ++i) { const auto& dev = pci::devices[i];