diff options
author | brapru <brapru@pm.me> | 2022-01-27 06:17:54 -0500 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-01-27 12:56:07 +0100 |
commit | 2af9a8e8628914420195f5e597f0189ac9df5dfc (patch) | |
tree | bdb45fc14cb2b5d6d12030d0b257f0064b8dc4f9 /Userland/Utilities | |
parent | 31c109457729f6ebb7c590f4303f185f8611f147 (diff) | |
download | serenity-2af9a8e8628914420195f5e597f0189ac9df5dfc.zip |
ping: Port to LibMain
Diffstat (limited to 'Userland/Utilities')
-rw-r--r-- | Userland/Utilities/CMakeLists.txt | 1 | ||||
-rw-r--r-- | Userland/Utilities/ping.cpp | 11 |
2 files changed, 6 insertions, 6 deletions
diff --git a/Userland/Utilities/CMakeLists.txt b/Userland/Utilities/CMakeLists.txt index fae2e0e71e..6d821e833c 100644 --- a/Userland/Utilities/CMakeLists.txt +++ b/Userland/Utilities/CMakeLists.txt @@ -142,6 +142,7 @@ target_link_libraries(pape LibGUI) target_link_libraries(passwd LibCrypt LibMain) target_link_libraries(paste LibGUI) target_link_libraries(pgrep LibRegex) +target_link_libraries(ping LibMain) target_link_libraries(pls LibCrypt LibMain) target_link_libraries(pmap LibMain) target_link_libraries(pmemdump LibMain) diff --git a/Userland/Utilities/ping.cpp b/Userland/Utilities/ping.cpp index df24b8303a..c8782b85dd 100644 --- a/Userland/Utilities/ping.cpp +++ b/Userland/Utilities/ping.cpp @@ -7,6 +7,8 @@ #include <AK/Assertions.h> #include <AK/ByteBuffer.h> #include <LibCore/ArgsParser.h> +#include <LibCore/System.h> +#include <LibMain/Main.h> #include <arpa/inet.h> #include <errno.h> #include <netdb.h> @@ -55,18 +57,15 @@ static void closing_statistics() exit(0); }; -int main(int argc, char** argv) +ErrorOr<int> serenity_main(Main::Arguments arguments) { - if (pledge("stdio id inet unix sigaction", nullptr) < 0) { - perror("pledge"); - return 1; - } + TRY(Core::System::pledge("stdio id inet unix sigaction")); Core::ArgsParser args_parser; args_parser.add_positional_argument(host, "Host to ping", "host"); args_parser.add_option(count, "Stop after sending specified number of ECHO_REQUEST packets.", "count", 'c', "count"); args_parser.add_option(payload_size, "Amount of bytes to send as payload in the ECHO_REQUEST packets.", "size", 's', "size"); - args_parser.parse(argc, argv); + args_parser.parse(arguments); if (payload_size < 0) { // Use the default. |