Fix Musl incompabilities

Without including libgen.h, basename is not available on Musl.
sourceArgv[0] is a const char* which can not be converted to char*, so
cast it instead
RTLD_DEEPBIND is not available on Musl, only on glibc (since 2.3.4)
ARG_MAX is already defined so it has to be renamed
Even according to glibc itself, <bits/socket.h> should never be included
directly and <sys/socket.h> should, which is already done anyway
pull/1/head
Bart Ribbers 6 years ago
parent 7e93b143a1
commit 6d31938929

@ -26,7 +26,6 @@
#include <string.h> #include <string.h>
#include <signal.h> #include <signal.h>
#include <sys/socket.h> #include <sys/socket.h>
#include <bits/socket.h>
#include <sys/un.h> #include <sys/un.h>
#include <sys/uio.h> #include <sys/uio.h>
#include <sys/time.h> #include <sys/time.h>

@ -46,6 +46,7 @@
#include <sys/types.h> #include <sys/types.h>
#include <sys/socket.h> #include <sys/socket.h>
#include <grp.h> #include <grp.h>
#include <libgen.h>
#include "coverage.h" #include "coverage.h"
@ -327,9 +328,12 @@ void Booster::renameProcess(int parentArgc, char** parentArgv,
} }
// Set the process name using prctl, 'killall' and 'top' use it // Set the process name using prctl, 'killall' and 'top' use it
if ( prctl(PR_SET_NAME, basename(sourceArgv[0])) == -1 ) char* processName = strdup(sourceArgv[0]);
if ( prctl(PR_SET_NAME, basename(processName)) == -1 )
Logger::logError("Booster: on set new process name: %s ", strerror(errno)); Logger::logError("Booster: on set new process name: %s ", strerror(errno));
std::free(processName);
setenv("_", sourceArgv[0], true); setenv("_", sourceArgv[0], true);
} }
} }
@ -583,7 +587,7 @@ void* Booster::loadMain()
else else
dlopenFlags |= RTLD_LOCAL; dlopenFlags |= RTLD_LOCAL;
#if (PLATFORM_ID == Linux) #if (PLATFORM_ID == Linux) && defined(__GLIBC__)
if (m_appData->dlopenDeep()) if (m_appData->dlopenDeep())
dlopenFlags |= RTLD_DEEPBIND; dlopenFlags |= RTLD_DEEPBIND;
#endif #endif

@ -281,8 +281,8 @@ bool Connection::receiveArgs()
{ {
// Get argc // Get argc
recvMsg(&m_argc); recvMsg(&m_argc);
const uint32_t ARG_MAX = 1024; const uint32_t argMax = 1024;
if (m_argc > 0 && m_argc < ARG_MAX) if (m_argc > 0 && m_argc < argMax)
{ {
// Reserve memory for argv // Reserve memory for argv
m_argv = new const char * [m_argc]; m_argv = new const char * [m_argc];

Loading…
Cancel
Save