From: Michael Tremer Date: Thu, 21 Jul 2022 10:36:23 +0000 (+0000) Subject: tests: command: Print PID X-Git-Tag: 0.9.28~654 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=772f2b95aa4913d3f836ba33cfa35ef5ee03d85f;p=pakfire.git tests: command: Print PID Signed-off-by: Michael Tremer --- diff --git a/tests/stub/command.c b/tests/stub/command.c index 5906c7b70..6ee1f20b7 100644 --- a/tests/stub/command.c +++ b/tests/stub/command.c @@ -154,6 +154,17 @@ static int lines(int argc, char* argv[]) { return 0; } +static int pid(int argc, char* argv[]) { + pid_t pid = getpid(); + if (!pid) + return 1; + + // Print the PID + printf("%d\n", pid); + + return 0; +} + int main(int argc, char* argv[]) { if (argc < 2) { fprintf(stderr, "No command given\n"); @@ -187,6 +198,10 @@ int main(int argc, char* argv[]) { else if (strcmp(command, "lines") == 0) callback = lines; + // Print PID + else if (strcmp(command, "pid") == 0) + callback = pid; + // Exit if no callback has been set if (!callback) { fprintf(stderr, "Unknown command: %s\n", command);