mirror of
https://github.com/apache/nuttx.git
synced 2026-10-12 00:30:23 +00:00
sched/task: Do not log a missing or unloadable program as an exec error.
posix_spawn() and execve() logged every failed exec at error level. A shell normally tries a program first: NSH with CONFIG_NSH_FILE_APPS spawns each command from PATH before its built-in command, and bash runs a script itself when execve() returns ENOEXEC. So every built-in NSH command printed nxposix_spawn_exec: ERROR: exec failed: 2 although nothing was wrong. The caller gets the error code and reports it if it needs to. Do not log ENOENT and ENOEXEC. Other errors are logged as before. Assisted-by: Claude Code:claude-opus-5-5 Signed-off-by: Marco Casaroli <marco.casaroli@gmail.com>
This commit is contained in:
parent
0072a34bc5
commit
7942d18fd5
2 changed files with 22 additions and 2 deletions
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue