summaryrefslogtreecommitdiff
path: root/apps/builtin/exec_builtin.c
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2013-01-17 20:25:32 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2013-01-17 20:25:32 +0000
commitc0ae392704e4e19f7c09fae1e753f777133afe8e (patch)
tree0944393494ed93baac50c117a4670a84c7e20039 /apps/builtin/exec_builtin.c
parent68453d683cb221e509258d71bddf207a330a1656 (diff)
downloadnuttx-c0ae392704e4e19f7c09fae1e753f777133afe8e.tar.gz
nuttx-c0ae392704e4e19f7c09fae1e753f777133afe8e.tar.bz2
nuttx-c0ae392704e4e19f7c09fae1e753f777133afe8e.zip
Misc bug fixes related to NSH file execution
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@5530 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'apps/builtin/exec_builtin.c')
-rw-r--r--apps/builtin/exec_builtin.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/apps/builtin/exec_builtin.c b/apps/builtin/exec_builtin.c
index d4431164c..803d1ef34 100644
--- a/apps/builtin/exec_builtin.c
+++ b/apps/builtin/exec_builtin.c
@@ -46,6 +46,7 @@
#include <nuttx/config.h>
+#include <sys/wait.h>
#include <sched.h>
#include <string.h>
#include <fcntl.h>
@@ -92,7 +93,9 @@ struct builtin_parms_s
****************************************************************************/
static sem_t g_builtin_parmsem = SEM_INITIALIZER(1);
+#ifndef CONFIG_SCHED_WAITPID
static sem_t g_builtin_execsem = SEM_INITIALIZER(0);
+#endif
static struct builtin_parms_s g_builtin_parms;
/****************************************************************************
@@ -274,7 +277,9 @@ static int builtin_proxy(int argc, char *argv[])
*/
g_builtin_parms.result = ret;
+#ifndef CONFIG_SCHED_WAITPID
builtin_semgive(&g_builtin_execsem);
+#endif
return 0;
}
@@ -299,6 +304,9 @@ static inline int builtin_startproxy(int index, FAR const char **argv,
struct sched_param param;
pid_t proxy;
int errcode;
+#ifdef CONFIG_SCHED_WAITPID
+ int status;
+#endif
int ret;
svdbg("index=%d argv=%p redirfile=%s oflags=%04x\n",
@@ -353,7 +361,15 @@ static inline int builtin_startproxy(int index, FAR const char **argv,
* for this.
*/
+#ifdef CONFIG_SCHED_WAITPID
+ ret = waitpid(proxy, &status, 0);
+ if (ret < 0)
+ {
+ sdbg("ERROR: waitpid() failed: %d\n", errno);
+ }
+#else
bultin_semtake(&g_builtin_execsem);
+#endif
/* Get the result and relinquish our access to the parameter structure */