From 5458286309067b48101de6c45a902bc9c6049169 Mon Sep 17 00:00:00 2001 From: apio Date: Fri, 21 Jul 2023 21:21:08 +0200 Subject: [PATCH] libos: Add Process::exit() --- libos/include/os/Process.h | 7 +++++++ libos/src/Process.cpp | 6 ++++++ 2 files changed, 13 insertions(+) diff --git a/libos/include/os/Process.h b/libos/include/os/Process.h index bcf902e9..ac2fa586 100644 --- a/libos/include/os/Process.h +++ b/libos/include/os/Process.h @@ -81,5 +81,12 @@ namespace os * @return Result Whether the function succeeded. */ static Result kill(pid_t pid, int signo); + + /** + * @brief Exit the current process. + * + * @param status The exit status code to return to the parent. + */ + [[noreturn]] static void exit(int status); }; } diff --git a/libos/src/Process.cpp b/libos/src/Process.cpp index cc896942..bf18e12b 100644 --- a/libos/src/Process.cpp +++ b/libos/src/Process.cpp @@ -9,6 +9,7 @@ #include #include +#include #include #include @@ -74,4 +75,9 @@ namespace os long rc = syscall(SYS_kill, pid, signo); return Result::from_syscall(rc); } + + [[noreturn]] void Process::exit(int status) + { + ::exit(status); + } }