From 9ccddde6a994b3d81facf4069d3d48d2f119ef89 Mon Sep 17 00:00:00 2001 From: Xiang Xiao Date: Sun, 16 Oct 2022 21:27:03 +0800 Subject: [PATCH] sched/spawn: Launch nxposix_spawn_proxy through nxthread_create to ensure the caller environment variable always get copied Signed-off-by: Xiang Xiao --- sched/sched/sched.h | 4 ++++ sched/task/task_create.c | 12 ++++-------- sched/task/task_posixspawn.c | 8 ++++---- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/sched/sched/sched.h b/sched/sched/sched.h index c876eb205b..37b7c51e5c 100644 --- a/sched/sched/sched.h +++ b/sched/sched/sched.h @@ -297,6 +297,10 @@ extern volatile spinlock_t g_cpu_tasklistlock; * Public Function Prototypes ****************************************************************************/ +int nxthread_create(FAR const char *name, uint8_t ttype, int priority, + FAR void *stack_ptr, int stack_size, main_t entry, + FAR char * const argv[], FAR char * const envp[]); + /* Task list manipulation functions */ bool nxsched_add_readytorun(FAR struct tcb_s *rtrtcb); diff --git a/sched/task/task_create.c b/sched/task/task_create.c index 11692184b0..0442a17355 100644 --- a/sched/task/task_create.c +++ b/sched/task/task_create.c @@ -39,7 +39,7 @@ #include "task/task.h" /**************************************************************************** - * Private Functions + * Public Functions ****************************************************************************/ /**************************************************************************** @@ -70,9 +70,9 @@ * ****************************************************************************/ -static int nxthread_create(FAR const char *name, uint8_t ttype, int priority, - FAR void *stack_ptr, int stack_size, main_t entry, - FAR char * const argv[], FAR char * const envp[]) +int nxthread_create(FAR const char *name, uint8_t ttype, int priority, + FAR void *stack_ptr, int stack_size, main_t entry, + FAR char * const argv[], FAR char * const envp[]) { FAR struct task_tcb_s *tcb; pid_t pid; @@ -112,10 +112,6 @@ static int nxthread_create(FAR const char *name, uint8_t ttype, int priority, return (int)pid; } -/**************************************************************************** - * Public Functions - ****************************************************************************/ - /**************************************************************************** * Name: nxtask_create * diff --git a/sched/task/task_posixspawn.c b/sched/task/task_posixspawn.c index 8d7e357049..b451291ed5 100644 --- a/sched/task/task_posixspawn.c +++ b/sched/task/task_posixspawn.c @@ -388,10 +388,10 @@ int posix_spawn(FAR pid_t *pid, FAR const char *path, * task. */ - proxy = kthread_create("nxposix_spawn_proxy", param.sched_priority, - CONFIG_POSIX_SPAWN_PROXY_STACKSIZE, - (main_t)nxposix_spawn_proxy, - (FAR char * const *)NULL); + proxy = nxthread_create("nxposix_spawn_proxy", TCB_FLAG_TTYPE_KERNEL, + param.sched_priority, NULL, + CONFIG_POSIX_SPAWN_PROXY_STACKSIZE, + nxposix_spawn_proxy, NULL, environ); if (proxy < 0) { ret = -proxy;