diff --git a/sched/task/task_execve.c b/sched/task/task_execve.c index f070ce29513..0971509a33c 100644 --- a/sched/task/task_execve.c +++ b/sched/task/task_execve.c @@ -128,7 +128,17 @@ int execve(FAR const char *path, FAR char * const argv[], ret = exec(path, argv, envp, symtab, nsymbols); if (ret < 0) { - serr("ERROR: exec failed: %d\n", get_errno()); + /* No such program (ENOENT) or not a loadable format (ENOEXEC) is an + * ordinary result for the caller, for example a shell that runs a + * script itself when execve() cannot. + */ + + ret = get_errno(); + if (ret != ENOENT && ret != ENOEXEC) + { + serr("ERROR: exec failed: %d\n", ret); + } + return ERROR; } diff --git a/sched/task/task_posixspawn.c b/sched/task/task_posixspawn.c index cc896c75717..b94b5d1f4c6 100644 --- a/sched/task/task_posixspawn.c +++ b/sched/task/task_posixspawn.c @@ -110,7 +110,17 @@ static int nxposix_spawn_exec(FAR pid_t *pidp, FAR const char *path, if (pid < 0) { ret = -pid; - serr("ERROR: exec failed: %d\n", ret); + + /* No such program (ENOENT) or not a loadable format (ENOEXEC) is an + * ordinary result for the caller, for example a shell that tries a + * program before its built-in command. + */ + + if (ret != ENOENT && ret != ENOEXEC) + { + serr("ERROR: exec failed: %d\n", ret); + } + return ret; }