Skip to content

Commit 37d70a6

Browse files
authored
Merge pull request #7153 from mcoil1/pr/fix-misleading-error-message
fix misleading error message with missing #! interpreter
2 parents b50d568 + 9b73f6a commit 37d70a6

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

orte/mca/odls/default/odls_default_module.c

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -454,11 +454,22 @@ static int do_child(orte_odls_spawn_caddy_t *cd, int write_fd)
454454

455455
/* Exec the new executable */
456456
execve(cd->cmd, cd->argv, cd->env);
457-
getcwd(dir, sizeof(dir));
457+
/* If we get here, an error has occurred. */
458+
(void) getcwd(dir, sizeof(dir));
459+
struct stat stats;
460+
char* msg;
461+
/* If errno is ENOENT, that indicates either cd->cmd does not exist, or
462+
* cd->cmd is a script, but has a bad interpreter specified. */
463+
if (ENOENT == errno && 0 == stat(cd->app->app, &stats)) {
464+
asprintf(&msg, "%s has a bad interpreter on the first line.",
465+
cd->app->app);
466+
} else {
467+
msg = strdup(strerror(errno));
468+
}
458469
send_error_show_help(write_fd, 1,
459470
"help-orte-odls-default.txt", "execve error",
460-
orte_process_info.nodename, dir, cd->app->app, strerror(errno));
461-
/* Does not return */
471+
orte_process_info.nodename, dir, cd->app->app, msg);
472+
free(msg);
462473
}
463474

464475

0 commit comments

Comments
 (0)