aboutsummaryrefslogtreecommitdiff
path: root/apps/nshlib
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2013-01-18 01:52:42 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2013-01-18 01:52:42 +0000
commit76753ad9cb67133892000f19de10f93de78bb525 (patch)
tree1eae1d92a03b0a2cbd1e83b45704a24d8662cf17 /apps/nshlib
parent2f653578c632ec95e94f67306af24c7d82700d28 (diff)
downloadpx4-firmware-76753ad9cb67133892000f19de10f93de78bb525.tar.gz
px4-firmware-76753ad9cb67133892000f19de10f93de78bb525.tar.bz2
px4-firmware-76753ad9cb67133892000f19de10f93de78bb525.zip
Add internal API task_reparent(), used in posix_spawn(). Move libc/spawn/lib_ps.c to sched/task_posixspawn.c; Move libc/spawn/spawn.h to include/nuttx/spawn.h
git-svn-id: http://svn.code.sf.net/p/nuttx/code/trunk@5531 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'apps/nshlib')
-rw-r--r--apps/nshlib/nsh_builtin.c26
-rw-r--r--apps/nshlib/nsh_fileapps.c21
2 files changed, 29 insertions, 18 deletions
diff --git a/apps/nshlib/nsh_builtin.c b/apps/nshlib/nsh_builtin.c
index 343a0824b..0d5a0231c 100644
--- a/apps/nshlib/nsh_builtin.c
+++ b/apps/nshlib/nsh_builtin.c
@@ -131,12 +131,14 @@ int nsh_builtin(FAR struct nsh_vtbl_s *vtbl, FAR const char *cmd,
{
/* 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.
+ * the scheduler is locked. But in the case where I/O was redirected, a
+ * proxy task ran and broke our lock. As result, the application may
+ * have aso ran if its priority was higher than than the priority of
+ * this thread.
*
- * 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:
+ * If the application did not run to completion 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
@@ -156,11 +158,17 @@ int nsh_builtin(FAR struct nsh_vtbl_s *vtbl, FAR const char *cmd,
{
int rc = 0;
- /* Wait for the application to exit. We did locked the scheduler
+ /* Wait for the application to exit. We did lock the scheduler
* above, but that does not guarantee that the application did not
- * run in the case where I/O was redirected. The scheduler will
- * be unlocked while waitpid is waiting and if the application has
- * not yet run, it will be able to to do so.
+ * already run to completion in the case where I/O was redirected.
+ * Here the scheduler will be unlocked while waitpid is waiting
+ * and if the application has not yet run, it will now be able to
+ * do so.
+ *
+ * Also, if CONFIG_SCHED_HAVE_PARENT is defined waitpid() might fail
+ * even if task is still active: If the I/O was re-directed by a
+ * proxy task, then the ask is a child of the proxy, and not this
+ * task. waitpid() fails with ECHILD in either case.
*/
ret = waitpid(ret, &rc, 0);
diff --git a/apps/nshlib/nsh_fileapps.c b/apps/nshlib/nsh_fileapps.c
index 92146a68d..9ff230f1a 100644
--- a/apps/nshlib/nsh_fileapps.c
+++ b/apps/nshlib/nsh_fileapps.c
@@ -168,12 +168,14 @@ int nsh_fileapp(FAR struct nsh_vtbl_s *vtbl, FAR const char *cmd,
{
/* 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.
+ * the scheduler is locked. But in the case where I/O was redirected, a
+ * proxy task ran and broke our lock. As result, the application may
+ * have aso ran if its priority was higher than than the priority of
+ * this thread.
*
- * 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:
+ * If the application did not run to completion 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
@@ -193,11 +195,12 @@ int nsh_fileapp(FAR struct nsh_vtbl_s *vtbl, FAR const char *cmd,
{
int rc = 0;
- /* Wait for the application to exit. We did locked the scheduler
+ /* Wait for the application to exit. We did lock the scheduler
* above, but that does not guarantee that the application did not
- * run in the case where I/O was redirected. The scheduler will
- * be unlocked while waitpid is waiting and if the application has
- * not yet run, it will be able to to do so.
+ * already run to completion in the case where I/O was redirected.
+ * Here the scheduler will be unlocked while waitpid is waiting
+ * and if the application has not yet run, it will now be able to
+ * do so.
*/
ret = waitpid(pid, &rc, 0);