From 6db39da60240e4cad5e9a257bc4878efbefb8b6a Mon Sep 17 00:00:00 2001 From: Juha Sointusalo Date: Sat, 22 Sep 2018 18:10:30 +0300 Subject: [PATCH] lib: change run_program() to use $PATH GPU detection tries to launch a copy of the client using full path to the client executable but getting the full path may fail. In this case the code falls back to using argv[0] but argv[0] doesn't always contain path to the client. This may happen if the client was started from shell and the shell used $PATH to find the client executable. Change run_program() to search $PATH for the program file if the file name doesn't include path. --- lib/util.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/util.cpp b/lib/util.cpp index 642d16b000..29984d8578 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; @@ -436,7 +436,7 @@ int run_program( } retval = CreateProcessA( - file, + NULL, cmdline, NULL, NULL, @@ -479,11 +479,11 @@ int run_program( retval = chdir(dir); if (retval) return retval; } - execv(file, argv); + execvp(file, argv); #ifdef _USING_FCGI_ - FCGI::perror("execv"); + FCGI::perror("execvp"); #else - perror("execv"); + perror("execvp"); #endif exit(errno); }