diff --git a/client/gpu_detect.cpp b/client/gpu_detect.cpp index a1e931a434b..7e4e1302d6b 100644 --- a/client/gpu_detect.cpp +++ b/client/gpu_detect.cpp @@ -598,7 +598,6 @@ int COPROCS::launch_child_process_to_detect_gpus() { #else int prog; #endif - char quoted_client_path[MAXPATHLEN]; char quoted_data_dir[MAXPATHLEN+2]; char data_dir[MAXPATHLEN]; int retval = 0; @@ -625,22 +624,17 @@ int COPROCS::launch_child_process_to_detect_gpus() { boinc_getcwd(data_dir); #ifdef _WIN32 - strlcpy(quoted_client_path, "\"", sizeof(quoted_client_path)); - strlcat(quoted_client_path, client_path, sizeof(quoted_client_path)); - strlcat(quoted_client_path, "\"", sizeof(quoted_client_path)); - strlcpy(quoted_data_dir, "\"", sizeof(quoted_data_dir)); strlcat(quoted_data_dir, data_dir, sizeof(quoted_data_dir)); strlcat(quoted_data_dir, "\"", sizeof(quoted_data_dir)); #else - strlcpy(quoted_client_path, client_path, sizeof(quoted_client_path)); strlcpy(quoted_data_dir, data_dir, sizeof(quoted_data_dir)); #endif if (log_flags.coproc_debug) { msg_printf(0, MSG_INFO, "[coproc] launching child process at %s", - quoted_client_path + client_path ); if (!is_path_absolute(client_path)) { msg_printf(0, MSG_INFO, @@ -656,7 +650,7 @@ int COPROCS::launch_child_process_to_detect_gpus() { int argc = 4; char* const argv[5] = { - const_cast(quoted_client_path), + const_cast(client_path), const_cast("--detect_gpus"), const_cast("--dir"), const_cast(quoted_data_dir), diff --git a/clientgui/AdvancedFrame.cpp b/clientgui/AdvancedFrame.cpp index 47940d8554d..9bdf1958784 100644 --- a/clientgui/AdvancedFrame.cpp +++ b/clientgui/AdvancedFrame.cpp @@ -1590,18 +1590,18 @@ void CAdvancedFrame::OnLaunchNewInstance(wxCommandEvent& WXUNUSED(event)) { #else int prog; #endif + wxString strExecutable = wxGetApp().GetRootDirectory() + wxGetApp().GetExecutableName(); + wxCharBuffer mbStrExecutable = strExecutable.mb_str(); int argc = 2; char* const argv[3] = { - const_cast("boincmgr"), + mbStrExecutable.data(), const_cast("--multiple"), NULL }; - wxString strExecutable = wxGetApp().GetRootDirectory() + wxGetApp().GetExecutableName(); - run_program( wxGetApp().GetRootDirectory().mb_str(), - strExecutable.mb_str(), + mbStrExecutable, argc, argv, 2.0, diff --git a/clientgui/MainDocument.cpp b/clientgui/MainDocument.cpp index 14bc2d242d5..be04c0d6d9d 100644 --- a/clientgui/MainDocument.cpp +++ b/clientgui/MainDocument.cpp @@ -1803,17 +1803,19 @@ int CMainDocument::WorkShowGraphics(RESULT* rp) { ); } #else - char* argv[2]; - // If graphics app is already running, don't launch a second instance // if (previous_gfx_app) return 0; - argv[0] = 0; + + char* argv[2] = { + rp->graphics_exec_path, + NULL + }; iRetVal = run_program( rp->slot_path, rp->graphics_exec_path, - 0, + 1, argv, 0, id diff --git a/clientscr/screensaver.cpp b/clientscr/screensaver.cpp index 37ab545b40a..b02f56228bd 100644 --- a/clientscr/screensaver.cpp +++ b/clientscr/screensaver.cpp @@ -243,7 +243,7 @@ int CScreensaver::launch_screensaver(RESULT* rp, GFXAPP_ID& graphics_application } #else char* argv[3]; - argv[0] = "app_graphics"; // not used + argv[0] = rp->graphics_exec_path; argv[1] = "--fullscreen"; argv[2] = 0; retval = run_program( @@ -392,10 +392,6 @@ int CScreensaver::launch_default_screensaver(char *dir_path, GFXAPP_ID& graphics BOINCTRACE(_T("launch_default_screensaver returned %d\n"), retval); #else - // For unknown reasons, the graphics application exits with - // "RegisterProcess failed (error = -50)" unless we pass its - // full path twice in the argument list to execv on Macs. - char* argv[4]; char full_path[1024]; @@ -403,7 +399,7 @@ int CScreensaver::launch_default_screensaver(char *dir_path, GFXAPP_ID& graphics strlcat(full_path, PATH_SEPARATOR, sizeof(full_path)); strlcat(full_path, THE_DEFAULT_SS_EXECUTABLE, sizeof(full_path)); - argv[0] = full_path; // not used + argv[0] = full_path; argv[1] = "--fullscreen"; argv[2] = 0; argv[3] = 0; diff --git a/lib/util.cpp b/lib/util.cpp index 5a38f4ff3e7..bd3214aba38 100644 --- a/lib/util.cpp +++ b/lib/util.cpp @@ -414,7 +414,7 @@ int read_file_string( #ifdef _WIN32 int run_program( - const char* dir, const char* /*file*/, int argc, char *const argv[], double nsecs, HANDLE& id + const char* dir, const char* file, int argc, char *const argv[], double nsecs, HANDLE& id ) { int retval; PROCESS_INFORMATION process_info; @@ -427,12 +427,13 @@ int run_program( memset(&startup_info, 0, sizeof(startup_info)); startup_info.cb = sizeof(startup_info); - safe_strcpy(cmdline, ""); - for (int i=0; i