From ce1637e317cddb991f80f91b653ee429bb2cf01b Mon Sep 17 00:00:00 2001 From: Bart Ribbers Date: Fri, 18 Jun 2021 23:19:14 +0200 Subject: [PATCH] Make sure we use the POSIX basename rather than GNU's When we include libgen.h, POSIX's basename will be used rather than GNU's. Since we don't use the special functionalities of GNU's variant anyway, this helps to compile it on POSIX-compliant libc's like Musl. https://www.man7.org/linux/man-pages/man3/basename.3.html --- src/launcherlib/daemon.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/launcherlib/daemon.cpp b/src/launcherlib/daemon.cpp index b70b377..8a78409 100644 --- a/src/launcherlib/daemon.cpp +++ b/src/launcherlib/daemon.cpp @@ -43,6 +43,7 @@ #include #include #include +#include #include #include #include @@ -979,7 +980,8 @@ void Daemon::parseArgs(int argc, char **argv) // Prints the usage and exits with given status void Daemon::usage(const char *name, int status) { - name = basename(name); + char *nameCopy = strdup(name); + name = basename(nameCopy); printf("\n" "Start the application launcher daemon.\n" "\n" @@ -1008,6 +1010,8 @@ void Daemon::usage(const char *name, int status) "\n", name, name, name); + free(nameCopy); + exit(status); }