forked from Mirrors/openclonk
Launch editor via argv[0] on Unix systems without /proc/self/exe (#1999)
parent
9855f9355e
commit
55a81ea76a
|
@ -192,7 +192,7 @@ void C4Application::ClearCommandLine()
|
|||
|
||||
void C4Application::ParseCommandLine(int argc, char * argv[])
|
||||
{
|
||||
|
||||
argv0 = argv[0];
|
||||
StdStrBuf CmdLine("Command line:");
|
||||
for(int i = 0; i < argc; ++i) {
|
||||
CmdLine.Append(" ");
|
||||
|
|
|
@ -72,6 +72,7 @@ public:
|
|||
const char *GetRevision() const { return Revision.c_str(); }
|
||||
|
||||
// set by ParseCommandLine
|
||||
const char *argv0;
|
||||
int isEditor{false};
|
||||
// set by ParseCommandLine, for manually applying downloaded update packs
|
||||
std::string IncomingUpdate;
|
||||
|
|
|
@ -98,18 +98,22 @@ bool RestartApplication(std::vector<const char *> parameters)
|
|||
intptr_t iError = (intptr_t)::ShellExecute(nullptr, nullptr, buf, params.GetWideChar(), Config.General.ExePath.GetWideChar(), SW_SHOW);
|
||||
if (iError > 32) success = true;
|
||||
}
|
||||
#elif defined(PROC_SELF_EXE)
|
||||
#else
|
||||
pid_t pid;
|
||||
switch (pid = fork())
|
||||
{
|
||||
case -1: break; // error message shown below
|
||||
case 0:
|
||||
{
|
||||
std::vector<const char*> params = {"openclonk"};
|
||||
std::vector<const char*> params = {Application.argv0};
|
||||
params.insert(params.end(), parameters.begin(), parameters.end());
|
||||
params.push_back(nullptr);
|
||||
#ifdef PROC_SELF_EXE
|
||||
execv(PROC_SELF_EXE, const_cast<char *const *>(params.data()));
|
||||
perror("editor launch failed");
|
||||
perror("editor launch via " PROC_SELF_EXE " failed");
|
||||
#endif
|
||||
execvp(Application.argv0, const_cast<char *const *>(params.data()));
|
||||
perror("editor launch via argv[0] failed");
|
||||
exit(1);
|
||||
}
|
||||
default:
|
||||
|
|
Loading…
Reference in New Issue