forked from Mirrors/openclonk
Autodetect "/proc/self/exe"-equivalent on FreeBSD (#1999)
parent
cd1f540b1e
commit
a091874546
|
@ -299,6 +299,17 @@ if(UNIX AND NOT APPLE)
|
||||||
if(Backward_FOUND)
|
if(Backward_FOUND)
|
||||||
set(HAVE_BACKWARD 1)
|
set(HAVE_BACKWARD 1)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(NOT DEFINED PROC_SELF_EXE)
|
||||||
|
macro(FIND_PROC_SELF_EXE path)
|
||||||
|
if(EXISTS ${path})
|
||||||
|
set(PROC_SELF_EXE ${path} CACHE FILEPATH "Path to /proc/self/exe (Linux) or equivalent")
|
||||||
|
endif()
|
||||||
|
endmacro()
|
||||||
|
FIND_PROC_SELF_EXE(/proc/self/exe) # Linux
|
||||||
|
FIND_PROC_SELF_EXE(/proc/curproc/file) # FreeBSD
|
||||||
|
FIND_PROC_SELF_EXE(/proc/curproc/exe) # NetBSD
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (WIN32)
|
if (WIN32)
|
||||||
|
|
|
@ -118,3 +118,6 @@
|
||||||
|
|
||||||
/* Include OpenAL extensions (alext.h) for sound modifiers */
|
/* Include OpenAL extensions (alext.h) for sound modifiers */
|
||||||
#cmakedefine HAVE_ALEXT 1
|
#cmakedefine HAVE_ALEXT 1
|
||||||
|
|
||||||
|
/* Path to /proc/self/exe (Linux) or equivalent */
|
||||||
|
#cmakedefine PROC_SELF_EXE "${PROC_SELF_EXE}"
|
||||||
|
|
|
@ -443,9 +443,9 @@ void C4ConfigGeneral::DeterminePaths()
|
||||||
GetTempPathW(CFG_MaxString,apath);
|
GetTempPathW(CFG_MaxString,apath);
|
||||||
TempPath = StdStrBuf(apath);
|
TempPath = StdStrBuf(apath);
|
||||||
if (TempPath[0]) TempPath.AppendBackslash();
|
if (TempPath[0]) TempPath.AppendBackslash();
|
||||||
#elif defined(__linux__)
|
#elif defined(PROC_SELF_EXE)
|
||||||
ExePath.SetLength(1024);
|
ExePath.SetLength(1024);
|
||||||
ssize_t l = readlink("/proc/self/exe", ExePath.getMData(), 1024);
|
ssize_t l = readlink(PROC_SELF_EXE, ExePath.getMData(), 1024);
|
||||||
if (l < -1)
|
if (l < -1)
|
||||||
{
|
{
|
||||||
ExePath.Ref(".");
|
ExePath.Ref(".");
|
||||||
|
|
|
@ -98,7 +98,7 @@ bool RestartApplication(std::vector<const char *> parameters)
|
||||||
intptr_t iError = (intptr_t)::ShellExecute(nullptr, nullptr, buf, params.GetWideChar(), Config.General.ExePath.GetWideChar(), SW_SHOW);
|
intptr_t iError = (intptr_t)::ShellExecute(nullptr, nullptr, buf, params.GetWideChar(), Config.General.ExePath.GetWideChar(), SW_SHOW);
|
||||||
if (iError > 32) success = true;
|
if (iError > 32) success = true;
|
||||||
}
|
}
|
||||||
#else
|
#elif defined(PROC_SELF_EXE)
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
switch (pid = fork())
|
switch (pid = fork())
|
||||||
{
|
{
|
||||||
|
@ -108,7 +108,7 @@ bool RestartApplication(std::vector<const char *> parameters)
|
||||||
std::vector<const char*> params = {"openclonk"};
|
std::vector<const char*> params = {"openclonk"};
|
||||||
params.insert(params.end(), parameters.begin(), parameters.end());
|
params.insert(params.end(), parameters.begin(), parameters.end());
|
||||||
params.push_back(nullptr);
|
params.push_back(nullptr);
|
||||||
execv("/proc/self/exe", const_cast<char *const *>(params.data()));
|
execv(PROC_SELF_EXE, const_cast<char *const *>(params.data()));
|
||||||
perror("editor launch failed");
|
perror("editor launch failed");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue