diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2013-01-17 18:32:13 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2013-01-17 18:32:13 +0000 |
commit | 19e43efe230a2b8720d98cba5a6ad156942e291f (patch) | |
tree | 677aa6a3af5241be04684f2d02eb0e719234b68c /apps/nshlib/nsh_builtin.c | |
parent | e9d0885500d437cc6c89370d8131913bd1e7310b (diff) | |
download | px4-firmware-19e43efe230a2b8720d98cba5a6ad156942e291f.tar.gz px4-firmware-19e43efe230a2b8720d98cba5a6ad156942e291f.tar.bz2 px4-firmware-19e43efe230a2b8720d98cba5a6ad156942e291f.zip |
NSH will now run files from the file system; Add logic to unload and clean-up after running a task from a file system; Extensions to builtin apps from Mike Smith
git-svn-id: http://svn.code.sf.net/p/nuttx/code/trunk@5529 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'apps/nshlib/nsh_builtin.c')
-rw-r--r-- | apps/nshlib/nsh_builtin.c | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/apps/nshlib/nsh_builtin.c b/apps/nshlib/nsh_builtin.c index ba39e8dfe..2d23ca8d8 100644 --- a/apps/nshlib/nsh_builtin.c +++ b/apps/nshlib/nsh_builtin.c @@ -51,6 +51,7 @@ #endif #include <stdbool.h> +#include <signal.h> #include <errno.h> #include <string.h> @@ -129,20 +130,34 @@ int nsh_builtin(FAR struct nsh_vtbl_s *vtbl, FAR const char *cmd, ret = exec_builtin(cmd, (FAR const char **)argv, redirfile, oflags); if (ret >= 0) { - /* The application was successfully started (but still blocked because - * the scheduler is locked). If the application was not backgrounded, - * then we need to wait here for the application to exit. These really - * only works works with the following options: + /* The application was successfully started with pre-emption disabled. + * In the simplest cases, the application will not have run because the + * the scheduler is locked. but in the case were I/O redirected, a + * proxy task ran and, as result, so may have the application. + * + * If the application did not run and if the application was not + * backgrounded, then we need to wait here for the application to + * exit. This only works works with the following options: * * - CONFIG_NSH_DISABLEBG - Do not run commands in background * - CONFIG_SCHED_WAITPID - Required to run external commands in * foreground - * - * These concepts do not apply cleanly to the external applications. */ #ifdef CONFIG_SCHED_WAITPID + /* Check if the application is still running */ + + if (kill(ret, 0) < 0) + { + /* It is not running. In this case, we have no idea if the + * application ran successfully or not. Let's assume that is + * did. + */ + + return 0; + } + /* CONFIG_SCHED_WAITPID is selected, so we may run the command in * foreground unless we were specifically requested to run the command * in background (and running commands in background is enabled). |