From 14a896b20509dfc4657778fa21246cffb2ec2b55 Mon Sep 17 00:00:00 2001 From: patacongo Date: Sun, 16 Dec 2012 21:15:27 +0000 Subject: Add basic hooks to support a PATH variable (more is needed) git-svn-id: http://svn.code.sf.net/p/nuttx/code/trunk@5440 42af7a65-404d-4744-a932-0658087f49c3 --- nuttx/sched/env_clearenv.c | 2 -- nuttx/sched/env_release.c | 4 ++-- nuttx/sched/os_bringup.c | 19 +++++++++++++++++++ nuttx/sched/os_start.c | 4 +++- 4 files changed, 24 insertions(+), 5 deletions(-) (limited to 'nuttx/sched') diff --git a/nuttx/sched/env_clearenv.c b/nuttx/sched/env_clearenv.c index 7fe97a911..75890f3bc 100644 --- a/nuttx/sched/env_clearenv.c +++ b/nuttx/sched/env_clearenv.c @@ -79,5 +79,3 @@ int clearenv(void) #endif /* CONFIG_DISABLE_ENVIRON */ - - diff --git a/nuttx/sched/env_release.c b/nuttx/sched/env_release.c index 83e65dbb5..8bc8d2205 100644 --- a/nuttx/sched/env_release.c +++ b/nuttx/sched/env_release.c @@ -94,11 +94,11 @@ int env_release(FAR _TCB *ptcb) { /* Check the reference count on the environment structure */ - if ( envp->ev_crefs <= 1) + if (envp->ev_crefs <= 1) { /* Decrementing the reference count will destroy the environment */ - sched_free( envp ); /* plain free() should be fine here */ + sched_free(envp); } else { diff --git a/nuttx/sched/os_bringup.c b/nuttx/sched/os_bringup.c index ec6152891..e0a236bbe 100644 --- a/nuttx/sched/os_bringup.c +++ b/nuttx/sched/os_bringup.c @@ -44,6 +44,7 @@ #include #include +#include #include #include @@ -129,6 +130,17 @@ int os_bringup(void) #endif int init_taskid; + /* Setup up the initial environment for the idle task. At present, this + * may consist of only the initial PATH variable. The PATH variable is + * (probably) not used by the IDLE task. However, the environment + * containing the PATH variable will be inherited by all of the threads + * created by the IDLE task. + */ + +#if !defined(CONFIG_DISABLE_ENVIRON) && defined(CONFIG_PATH_INITIAL) + (void)setenv("PATH", CONFIG_PATH_INITIAL, 1); +#endif + /* Start the page fill worker kernel thread that will resolve page faults. * This should always be the first thread started because it may have to * resolve page faults in other threads @@ -190,5 +202,12 @@ int os_bringup(void) (main_t)CONFIG_USER_ENTRYPOINT, (const char **)NULL); #endif ASSERT(init_taskid != ERROR); + + /* We an save a few bytes by discarding the IDLE thread's environment. */ + +#if !defined(CONFIG_DISABLE_ENVIRON) && defined(CONFIG_PATH_INITIAL) + (void)clearenv(); +#endif + return OK; } diff --git a/nuttx/sched/os_start.c b/nuttx/sched/os_start.c index c0b16236d..a53ac2aa8 100644 --- a/nuttx/sched/os_start.c +++ b/nuttx/sched/os_start.c @@ -426,7 +426,9 @@ void os_start(void) lib_initialize(); } - /* Create stdout, stderr, stdin */ + /* Create stdout, stderr, stdin on the IDLE task. These will be + * inherited by all of the threads created by the IDLE task. + */ (void)sched_setupidlefiles(&g_idletcb); -- cgit v1.2.3