diff --git a/Userland/Utilities/CMakeLists.txt b/Userland/Utilities/CMakeLists.txt index b28287470b..835d10cb07 100644 --- a/Userland/Utilities/CMakeLists.txt +++ b/Userland/Utilities/CMakeLists.txt @@ -194,7 +194,7 @@ target_link_libraries(tac LibMain) target_link_libraries(tail LibMain) target_link_libraries(tar LibMain LibArchive LibCompress) target_link_libraries(tee LibMain) -target_link_libraries(telws LibProtocol LibLine) +target_link_libraries(telws LibProtocol LibLine LibMain) target_link_libraries(test-fuzz LibCore LibGemini LibGfx LibHTTP LibIPC LibJS LibMarkdown LibShell) target_link_libraries(test-imap LibIMAP LibMain) target_link_libraries(test-pthread LibThreading) diff --git a/Userland/Utilities/telws.cpp b/Userland/Utilities/telws.cpp index 7d70d6f68b..23122dad2b 100644 --- a/Userland/Utilities/telws.cpp +++ b/Userland/Utilities/telws.cpp @@ -9,18 +9,15 @@ #include #include #include -#include -#include +#include #include +#include #include #include -int main(int argc, char** argv) +ErrorOr serenity_main(Main::Arguments arguments) { - if (pledge("stdio unix inet accept rpath wpath cpath fattr tty sigaction", nullptr) < 0) { - perror("pledge"); - return 1; - } + TRY(Core::System::pledge("stdio unix inet accept rpath wpath cpath fattr tty sigaction")); Core::ArgsParser args_parser; @@ -30,7 +27,7 @@ int main(int argc, char** argv) args_parser.add_positional_argument(url_string, "URL to connect to", "url", Core::ArgsParser::Required::Yes); args_parser.add_option(origin, "URL to use as origin", "origin", 'o', "origin"); - args_parser.parse(argc, argv); + args_parser.parse(arguments); URL url(url_string); @@ -44,6 +41,7 @@ int main(int argc, char** argv) auto maybe_websocket_client = Protocol::WebSocketClient::try_create(); if (maybe_websocket_client.is_error()) { warnln("Failed to connect to the websocket server: {}\n", maybe_websocket_client.error()); + return maybe_websocket_client.release_error(); } auto websocket_client = maybe_websocket_client.release_value(); @@ -76,15 +74,9 @@ int main(int argc, char** argv) Core::EventLoop::current().quit(0); }; - if (pledge("stdio unix inet accept rpath wpath tty sigaction", nullptr) < 0) { - perror("pledge"); - return 1; - } + TRY(Core::System::pledge("stdio unix inet accept rpath wpath tty sigaction")); - if (unveil(nullptr, nullptr) < 0) { - perror("unveil"); - return 1; - } + TRY(Core::System::unveil(nullptr, nullptr)); outln("Started server. Commands :"); outln("- '' send the text as message");