|
Lines 66-72
Link Here
|
| 66 |
/* Given a program name, translate it to a fully qualified pathname |
66 |
/* Given a program name, translate it to a fully qualified pathname |
| 67 |
* as needed based upon the PATH environment variable */ |
67 |
* as needed based upon the PATH environment variable */ |
| 68 |
static char * |
68 |
static char * |
| 69 |
_build_path(char* fname) |
69 |
_build_path(const char * cwd, char* fname) |
| 70 |
{ |
70 |
{ |
| 71 |
int i; |
71 |
int i; |
| 72 |
char *path_env = NULL, *dir = NULL, *ptrptr = NULL; |
72 |
char *path_env = NULL, *dir = NULL, *ptrptr = NULL; |
|
Lines 88-93
_build_path(char* fname)
Link Here
|
| 88 |
if ((file_name[0] == '/') || (file_name[0] == '.')) |
88 |
if ((file_name[0] == '/') || (file_name[0] == '.')) |
| 89 |
return file_name; |
89 |
return file_name; |
| 90 |
|
90 |
|
|
|
91 |
/* search for the file using cwd*/ |
| 92 |
snprintf(file_path, sizeof(file_path), "%s/%s", cwd, file_name); |
| 93 |
if ((stat(file_path, &buf) == 0) |
| 94 |
&& (! S_ISDIR(buf.st_mode))) |
| 95 |
return file_path; |
| 96 |
|
| 91 |
/* search for the file using PATH environment variable */ |
97 |
/* search for the file using PATH environment variable */ |
| 92 |
dir = getenv("PATH"); |
98 |
dir = getenv("PATH"); |
| 93 |
if (!dir) { |
99 |
if (!dir) { |
|
Lines 134-145
_set_range(int low_num, int high_num, char *exec_name, bool ignore_duplicates)
Link Here
|
| 134 |
} |
140 |
} |
| 135 |
|
141 |
|
| 136 |
static void |
142 |
static void |
| 137 |
_set_exec_names(char *ranks, char *exec_name, int ntasks) |
143 |
_set_exec_names(char *ranks, const char *cwd, char *exec_name, int ntasks) |
| 138 |
{ |
144 |
{ |
| 139 |
char *ptrptr = NULL, *exec_path = NULL; |
145 |
char *ptrptr = NULL, *exec_path = NULL; |
| 140 |
int low_num, high_num, num, i; |
146 |
int low_num, high_num, num, i; |
| 141 |
|
147 |
|
| 142 |
exec_path = _build_path(exec_name); |
148 |
exec_path = _build_path(cwd, exec_name); |
| 143 |
if ((ranks[0] == '*') && (ranks[1] == '\0')) { |
149 |
if ((ranks[0] == '*') && (ranks[1] == '\0')) { |
| 144 |
low_num = 0; |
150 |
low_num = 0; |
| 145 |
high_num = ntasks - 1; |
151 |
high_num = ntasks - 1; |
|
Lines 179-185
_set_exec_names(char *ranks, char *exec_name, int ntasks)
Link Here
|
| 179 |
} |
185 |
} |
| 180 |
|
186 |
|
| 181 |
extern int |
187 |
extern int |
| 182 |
mpir_set_multi_name(int ntasks, const char *config_fname) |
188 |
mpir_set_multi_name(int ntasks, const char *config_fname, const char * cwd) |
| 183 |
{ |
189 |
{ |
| 184 |
FILE *config_fd; |
190 |
FILE *config_fd; |
| 185 |
char line[BUF_SIZE]; |
191 |
char line[BUF_SIZE]; |
|
Lines 244-250
mpir_set_multi_name(int ntasks, const char *config_fname)
Link Here
|
| 244 |
fclose(config_fd); |
250 |
fclose(config_fd); |
| 245 |
return -1; |
251 |
return -1; |
| 246 |
} |
252 |
} |
| 247 |
_set_exec_names(ranks, exec_name, ntasks); |
253 |
_set_exec_names(ranks, cwd, exec_name, ntasks); |
| 248 |
} |
254 |
} |
| 249 |
fclose(config_fd); |
255 |
fclose(config_fd); |
| 250 |
return 0; |
256 |
return 0; |