diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2013-01-17 20:25:32 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2013-01-17 20:25:32 +0000 |
commit | 2f653578c632ec95e94f67306af24c7d82700d28 (patch) | |
tree | 0944393494ed93baac50c117a4670a84c7e20039 /nuttx/libc/spawn | |
parent | 19e43efe230a2b8720d98cba5a6ad156942e291f (diff) | |
download | px4-firmware-2f653578c632ec95e94f67306af24c7d82700d28.tar.gz px4-firmware-2f653578c632ec95e94f67306af24c7d82700d28.tar.bz2 px4-firmware-2f653578c632ec95e94f67306af24c7d82700d28.zip |
Misc bug fixes related to NSH file execution
git-svn-id: http://svn.code.sf.net/p/nuttx/code/trunk@5530 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/libc/spawn')
-rw-r--r-- | nuttx/libc/spawn/lib_ps.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/nuttx/libc/spawn/lib_ps.c b/nuttx/libc/spawn/lib_ps.c index 000f711a3..1bf7c2113 100644 --- a/nuttx/libc/spawn/lib_ps.c +++ b/nuttx/libc/spawn/lib_ps.c @@ -39,6 +39,7 @@ #include <nuttx/config.h> +#include <sys/wait.h> #include <semaphore.h> #include <signal.h> #include <sched.h> @@ -75,7 +76,9 @@ struct spawn_parms_s ****************************************************************************/ static sem_t g_ps_parmsem = SEM_INITIALIZER(1); +#ifndef CONFIG_SCHED_WAITPID static sem_t g_ps_execsem = SEM_INITIALIZER(0); +#endif static struct spawn_parms_s g_ps_parms; /**************************************************************************** @@ -425,7 +428,9 @@ static int spawn_proxy(int argc, char *argv[]) */ g_ps_parms.result = ret; +#ifndef CONFIG_SCHED_WAITPID ps_semgive(&g_ps_execsem); +#endif return 0; } @@ -540,6 +545,9 @@ int posix_spawn(FAR pid_t *pid, FAR const char *path, { struct sched_param param; pid_t proxy; +#ifdef CONFIG_SCHED_WAITPID + int status; +#endif int ret; DEBUGASSERT(path); @@ -613,7 +621,15 @@ int posix_spawn(FAR pid_t *pid, FAR const char *path, /* Wait for the proxy to complete its job */ +#ifdef CONFIG_SCHED_WAITPID + ret = waitpid(proxy, &status, 0); + if (ret < 0) + { + sdbg("ERROR: waitpid() failed: %d\n", errno); + } +#else ps_semtake(&g_ps_execsem); +#endif /* Get the result and relinquish our access to the parameter structure */ |