From: Michael Tremer Date: Wed, 10 Aug 2022 20:53:29 +0000 (+0000) Subject: command: Add sleep X-Git-Tag: 0.9.28~527 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e9f1ae19c50ceb2b77b460d273b0cebfb1e929be;p=pakfire.git command: Add sleep Signed-off-by: Michael Tremer --- diff --git a/tests/stub/command.c b/tests/stub/command.c index 0c0fd3068..9c9dc27f8 100644 --- a/tests/stub/command.c +++ b/tests/stub/command.c @@ -244,6 +244,23 @@ static int send_signal(int argc, char* argv[]) { return EXIT_SUCCESS; } +static int _sleep(int argc, char* argv[]) { + if (argc < 1) { + fprintf(stderr, "No timeout given\n"); + return EXIT_FAILURE; + } + + // Fetch timeout + unsigned int timeout = strtoul(argv[0], NULL, 10); + + printf("Sleeping for %u second(s)\n", timeout); + + // Sleep for given timeout + sleep(timeout); + + return EXIT_SUCCESS; +} + int main(int argc, char* argv[]) { if (argc < 2) { fprintf(stderr, "No command given\n"); @@ -292,6 +309,10 @@ int main(int argc, char* argv[]) { else if (strcmp(command, "send-signal") == 0) callback = send_signal; + // Sleep + else if (strcmp(command, "sleep") == 0) + callback = _sleep; + // Exit if no callback has been set if (!callback) { fprintf(stderr, "Unknown command: %s\n", command);