diff options
Diffstat (limited to 'nuttx/sched/task_vfork.c')
-rw-r--r-- | nuttx/sched/task_vfork.c | 34 |
1 files changed, 5 insertions, 29 deletions
diff --git a/nuttx/sched/task_vfork.c b/nuttx/sched/task_vfork.c index 7008a016e..58b4152ed 100644 --- a/nuttx/sched/task_vfork.c +++ b/nuttx/sched/task_vfork.c @@ -54,6 +54,9 @@ /**************************************************************************** * Pre-processor Definitions ****************************************************************************/ +/* vfork() requires architecture-specific support as well as waipid(). */ + +#if defined(CONFIG_ARCH_HAVE_VFORK) && defined(CONFIG_SCHED_WAITPID) /**************************************************************************** * Private Functions @@ -220,9 +223,7 @@ pid_t task_vforkstart(FAR struct task_tcb_s *child) #endif FAR const char *name; pid_t pid; -#ifdef CONFIG_SCHED_WAITPID int rc; -#endif int ret; svdbg("Starting Child TCB=%p, parent=%p\n", child, g_readytorun.head); @@ -279,8 +280,6 @@ pid_t task_vforkstart(FAR struct task_tcb_s *child) * after the parent thread again? */ -#ifdef CONFIG_SCHED_WAITPID - /* We can also exploit a bug in the execv() implementation: The PID * of the task exec'ed by the child will not be the same as the PID of * the child task. Therefore, waitpid() on the child task's PID will @@ -299,31 +298,6 @@ pid_t task_vforkstart(FAR struct task_tcb_s *child) (void)waitpid(pid, &rc, 0); #endif -#else - /* The following logic does not appear to work... It gets stuff in an - * infinite kill() loop and hogs the processor. Therefore, it looks - * as though CONFIG_SCHED_WAITPID may be a requirement to used vfork(). - * - * Again exploiting that execv() bug: Check if the child thread is - * still running. - */ - - while (kill(pid, 0) == OK) - { - /* Yes.. then we can yield to it -- assuming that it has not lowered - * its priority. sleep(0) might be a safer thing to do since it does - * not depend on prioirities: It will halt the parent thread for one - * system clock tick. This will delay the return to the parent thread. - */ - -#ifndef CONFIG_DISABLE_SIGNALS - sleep(0); -#else - sched_yield(); -#endif - } -#endif - return pid; } @@ -349,3 +323,5 @@ void task_vforkabort(FAR struct task_tcb_s *child, int errcode) sched_releasetcb((FAR struct tcb_s *)child); set_errno(errcode); } + +#endif /* CONFIG_ARCH_HAVE_VFORK && CONFIG_SCHED_WAITPID */ |