* Find another program in our binary's directory, * then make sure it is the proper version. */
| 324 | * then make sure it is the proper version. |
| 325 | */ |
| 326 | int |
| 327 | find_other_exec(const char *argv0, const char *target, |
| 328 | const char *versionstr, char *retpath) |
| 329 | { |
| 330 | char cmd[MAXPGPATH]; |
| 331 | char line[MAXPGPATH]; |
| 332 | |
| 333 | if (find_my_exec(argv0, retpath) < 0) |
| 334 | return -1; |
| 335 | |
| 336 | /* Trim off program name and keep just directory */ |
| 337 | *last_dir_separator(retpath) = '\0'; |
| 338 | canonicalize_path(retpath); |
| 339 | |
| 340 | /* Now append the other program's name */ |
| 341 | snprintf(retpath + strlen(retpath), MAXPGPATH - strlen(retpath), |
| 342 | "/%s%s", target, EXE); |
| 343 | |
| 344 | if (validate_exec(retpath) != 0) |
| 345 | return -1; |
| 346 | |
| 347 | snprintf(cmd, sizeof(cmd), "\"%s\" -V", retpath); |
| 348 | |
| 349 | if (!pipe_read_line(cmd, line, sizeof(line))) |
| 350 | return -1; |
| 351 | |
| 352 | if (strcmp(line, versionstr) != 0) |
| 353 | return -2; |
| 354 | |
| 355 | return 0; |
| 356 | } |
| 357 | |
| 358 | |
| 359 | /* |