diff --git a/nshlib/nsh_fileapps.c b/nshlib/nsh_fileapps.c index 98c50dffa..d64b37b11 100644 --- a/nshlib/nsh_fileapps.c +++ b/nshlib/nsh_fileapps.c @@ -34,6 +34,8 @@ #include #include #include +#include +#include #include "nsh.h" #include "nsh_console.h" @@ -73,6 +75,10 @@ int nsh_fileapp(FAR struct nsh_vtbl_s *vtbl, FAR const char *cmd, pid_t pid; int rc = 0; int ret; +#ifdef CONFIG_BUILTIN + FAR char *appname; + int index; +#endif /* Initialize the attributes file actions structure */ @@ -117,6 +123,42 @@ int nsh_fileapp(FAR struct nsh_vtbl_s *vtbl, FAR const char *cmd, } } +#ifdef CONFIG_BUILTIN + /* Check if a builtin application with this name exists */ + + appname = basename((FAR char *)cmd); + index = builtin_isavail(appname); + if (index >= 0) + { + FAR const struct builtin_s *builtin; + struct sched_param param; + + /* Get information about the builtin */ + + builtin = builtin_for_index(index); + if (builtin == NULL) + { + ret = ENOENT; + goto errout_with_actions; + } + + /* Set the correct task size and priority */ + + param.sched_priority = builtin->priority; + ret = posix_spawnattr_setschedparam(&attr, ¶m); + if (ret != 0) + { + goto errout_with_actions; + } + + ret = task_spawnattr_setstacksize(&attr, builtin->stacksize); + if (ret != 0) + { + goto errout_with_actions; + } + } +#endif + /* Lock the scheduler in an attempt to prevent the application from * running until waitpid() has been called. */