diff options
Diffstat (limited to 'Userland/Utilities/logout.cpp')
-rw-r--r-- | Userland/Utilities/logout.cpp | 29 |
1 files changed, 8 insertions, 21 deletions
diff --git a/Userland/Utilities/logout.cpp b/Userland/Utilities/logout.cpp index 0aedb63953..b9597c32ee 100644 --- a/Userland/Utilities/logout.cpp +++ b/Userland/Utilities/logout.cpp @@ -5,6 +5,8 @@ */ #include <LibCore/ProcessStatisticsReader.h> +#include <LibCore/System.h> +#include <LibMain/Main.h> #include <signal.h> static Core::ProcessStatistics const& get_proc(Core::AllProcessesStatistics const& stats, pid_t pid) @@ -16,24 +18,12 @@ static Core::ProcessStatistics const& get_proc(Core::AllProcessesStatistics cons VERIFY_NOT_REACHED(); } -int main(int, char**) +ErrorOr<int> serenity_main(Main::Arguments) { - if (pledge("stdio proc rpath", nullptr) < 0) { - perror("pledge"); - return 1; - } - - if (unveil("/proc/all", "r") < 0) { - perror("unveil"); - return 1; - } - - if (unveil("/etc/passwd", "r") < 0) { - perror("unveil"); - return 1; - } - - unveil(nullptr, nullptr); + TRY(Core::System::pledge("stdio proc rpath", nullptr)); + TRY(Core::System::unveil("/proc/all", "r")); + TRY(Core::System::unveil("/etc/passwd", "r")); + TRY(Core::System::unveil(nullptr, nullptr)); // logout finds the highest session up all nested sessions, and kills it. auto stats = Core::ProcessStatisticsReader::get_all(); @@ -53,10 +43,7 @@ int main(int, char**) sid = parent_sid; } - if (kill(-sid, SIGTERM) == -1) { - perror("kill(2)"); - return 1; - } + TRY(Core::System::kill(-sid, SIGTERM)); return 0; } |