You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2022/05/25 07:28:51 UTC

[incubator-nuttx] branch master updated (5d03e1a3b4 -> 5800dd2af5)

This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git


    from 5d03e1a3b4 esp32-devkitc: Document wamr_wasi_debug config
     new 622677d4a1 libc: Implement exit, atexit, on_exit and cxa_exit on the user side
     new a54c3d13f9 sched: Remove SCHED_ATEXIT / SCHED_ONEXIT
     new 5800dd2af5 boards/xxx: Remove CONFIG_SCHED_ATEXIT/ONEXIT from all defconfigs

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../arm/imx6/sabre-6quad/configs/libcxx/defconfig  |   2 +-
 .../lc823450-xgevk/configs/audio/defconfig         |   4 +-
 .../lc823450/lc823450-xgevk/configs/bt/defconfig   |   4 +-
 .../lc823450/lc823450-xgevk/configs/elf/defconfig  |   4 +-
 .../lc823450/lc823450-xgevk/configs/ipl2/defconfig |   4 +-
 .../lc823450/lc823450-xgevk/configs/knsh/defconfig |   4 +-
 .../lc823450-xgevk/configs/krndis/defconfig        |   4 +-
 .../lc823450/lc823450-xgevk/configs/nsh/defconfig  |   4 +-
 .../lc823450-xgevk/configs/posix_spawn/defconfig   |   4 +-
 .../lc823450-xgevk/configs/rndis/defconfig         |   4 +-
 .../lc823450/lc823450-xgevk/configs/usb/defconfig  |   4 +-
 .../lpcxpresso-lpc54628/configs/nxwm/defconfig     |   2 +-
 .../lpcxpresso-lpc54628/configs/pwfb/defconfig     |   2 +-
 .../lpcxpresso-lpc54628/configs/pwlines/defconfig  |   2 +-
 .../lpcxpresso-lpc54628/configs/twm4nx1/defconfig  |   2 +-
 .../lpcxpresso-lpc54628/configs/twm4nx2/defconfig  |   2 +-
 boards/arm/sam34/sam3u-ek/configs/nxwm/defconfig   |   2 +-
 boards/arm/sam34/sam4e-ek/configs/nxwm/defconfig   |   2 +-
 .../arm/sama5/sama5d3x-ek/configs/nxwm/defconfig   |   2 +-
 boards/arm/sama5/sama5d4-ek/configs/knsh/defconfig |   3 +-
 boards/arm/sama5/sama5d4-ek/configs/nxwm/defconfig |   2 +-
 .../arm/samv7/samv71-xult/configs/nxwm/defconfig   |   2 +-
 .../arm/samv7/samv71-xult/configs/vnxwm/defconfig  |   2 +-
 .../mikroe-stm32f4/configs/fulldemo/defconfig      |   3 +-
 .../stm32/mikroe-stm32f4/configs/kostest/defconfig |   3 +-
 boards/arm/stm32/shenzhou/configs/nxwm/defconfig   |   2 +-
 .../arm/stm32/stm3220g-eval/configs/nxwm/defconfig |   2 +-
 .../stm32/stm3240g-eval/configs/knxwm/defconfig    |   2 +-
 .../arm/stm32/stm3240g-eval/configs/nxwm/defconfig |   2 +-
 .../stm32f429i-disco/configs/nxhello/defconfig     |   2 +-
 .../stm32/stm32f429i-disco/configs/nxwm/defconfig  |   2 +-
 .../stm32f4discovery/configs/cxxtest/defconfig     |   3 +-
 .../stm32f4discovery/configs/testlibcxx/defconfig  |   3 +-
 .../stm32f746g-disco/configs/netnsh/defconfig      |   2 +-
 .../risc-v/bl602/bl602evb/configs/wifi/defconfig   |   2 +-
 .../esp32c3-devkit/configs/autopm/defconfig        |   1 +
 .../esp32c3/esp32c3-devkit/configs/cxx/defconfig   |   2 +-
 .../esp32c3-devkit/configs/sta_softap/defconfig    |   1 +
 .../esp32c3/esp32c3-devkit/configs/wapi/defconfig  |   1 +
 boards/risc-v/k210/maix-bit/configs/smp2/defconfig |   4 +-
 boards/risc-v/mpfs/icicle/configs/knsh/defconfig   |   3 +-
 boards/sim/sim/sim/configs/alsa/defconfig          |   2 +-
 boards/sim/sim/sim/configs/asan/defconfig          |   2 +-
 boards/sim/sim/sim/configs/bas/defconfig           |   2 +-
 boards/sim/sim/sim/configs/bastest/defconfig       |   2 +-
 boards/sim/sim/sim/configs/bluetooth/defconfig     |   2 +-
 boards/sim/sim/sim/configs/bthcisock/defconfig     |   2 +-
 boards/sim/sim/sim/configs/cxxtest/defconfig       |   3 +-
 boards/sim/sim/sim/configs/duktape/defconfig       |   2 +-
 boards/sim/sim/sim/configs/dynconns/defconfig      |   2 +-
 boards/sim/sim/sim/configs/elf/defconfig           |   2 +-
 boards/sim/sim/sim/configs/foc/defconfig           |   2 +-
 boards/sim/sim/sim/configs/ipforward/defconfig     |   2 +-
 boards/sim/sim/sim/configs/kasan/defconfig         |   2 +-
 boards/sim/sim/sim/configs/libcxxtest/defconfig    |   2 +-
 boards/sim/sim/sim/configs/linuxi2c/defconfig      |   2 +-
 boards/sim/sim/sim/configs/linuxspi/defconfig      |   2 +-
 boards/sim/sim/sim/configs/loadable/defconfig      |   2 +-
 boards/sim/sim/sim/configs/lua/defconfig           |   2 +-
 boards/sim/sim/sim/configs/minibasic/defconfig     |   2 +-
 boards/sim/sim/sim/configs/module/defconfig        |   2 +-
 boards/sim/sim/sim/configs/module32/defconfig      |   2 +-
 boards/sim/sim/sim/configs/nimble/defconfig        |   2 +-
 boards/sim/sim/sim/configs/note/defconfig          |   2 +-
 boards/sim/sim/sim/configs/nsh/defconfig           |   2 +-
 boards/sim/sim/sim/configs/nshcromfs/defconfig     |   2 +-
 boards/sim/sim/sim/configs/nxlines/defconfig       |   2 +-
 boards/sim/sim/sim/configs/nxwm/defconfig          |   2 +-
 boards/sim/sim/sim/configs/posix_spawn/defconfig   |   2 +-
 boards/sim/sim/sim/configs/rc/defconfig            |   2 +-
 boards/sim/sim/sim/configs/romfs/defconfig         |   2 +-
 boards/sim/sim/sim/configs/rust/defconfig          |   2 +-
 boards/sim/sim/sim/configs/segger/defconfig        |   2 +-
 boards/sim/sim/sim/configs/sensor/defconfig        |   2 +-
 boards/sim/sim/sim/configs/smartfs/defconfig       |   2 +-
 boards/sim/sim/sim/configs/sotest/defconfig        |   2 +-
 boards/sim/sim/sim/configs/sotest32/defconfig      |   2 +-
 boards/sim/sim/sim/configs/tcpblaster/defconfig    |   2 +-
 boards/sim/sim/sim/configs/tcploop/defconfig       |   2 +-
 boards/sim/sim/sim/configs/udgram/defconfig        |   2 +-
 boards/sim/sim/sim/configs/unionfs/defconfig       |   2 +-
 boards/sim/sim/sim/configs/userfs/defconfig        |   2 +-
 boards/sim/sim/sim/configs/ustream/defconfig       |   2 +-
 boards/sim/sim/sim/configs/vpnkit/defconfig        |   2 +-
 .../esp32/esp32-devkitc/configs/cxx/defconfig      |   2 +-
 .../esp32s2/esp32s2-saola-1/configs/cxx/defconfig  |   2 +-
 .../esp32s3/esp32s3-devkit/configs/cxx/defconfig   |   2 +-
 .../stm32/stm32_fdcan.h => include/nuttx/atexit.h  |  92 +++++----
 include/nuttx/sched.h                              |  48 -----
 include/nuttx/tls.h                                |   5 +
 include/sys/syscall_lookup.h                       |   8 -
 libs/libc/machine/arm/aeabi_atexit.c               |   9 +-
 libs/libc/pthread/pthread_cleanup.c                |   7 +-
 libs/libc/stdlib/Kconfig                           |   7 +
 libs/libc/stdlib/Make.defs                         |   6 +-
 libs/libc/stdlib/lib__Exit.c                       |  35 ----
 libs/libc/stdlib/lib_atexit.c                      | 221 +++++++++++++++++++++
 .../lib_cxa_atexit.c}                              |  38 ++--
 .../lpc31_buttons.c => libs/libc/stdlib/lib_exit.c |  39 ++--
 .../task_onexit.c => libs/libc/stdlib/lib_onexit.c |  57 +-----
 libs/libc/unistd/lib_sysconf.c                     |   8 +-
 libs/libxx/Makefile                                |   2 -
 libs/libxx/libxx.hxx                               |  49 -----
 libs/libxx/libxx_cxa_atexit.cxx                    | 130 ------------
 sched/Kconfig                                      |  39 ----
 sched/task/Make.defs                               |   8 -
 sched/task/exit.c                                  |  30 +--
 sched/task/task_atexit.c                           | 133 -------------
 sched/task/task_exithook.c                         | 143 -------------
 syscall/syscall.csv                                |   2 -
 110 files changed, 425 insertions(+), 891 deletions(-)
 copy arch/arm/src/stm32/stm32_fdcan.h => include/nuttx/atexit.h (62%)
 delete mode 100644 libs/libc/stdlib/lib__Exit.c
 create mode 100644 libs/libc/stdlib/lib_atexit.c
 copy libs/libc/{pthread/pthread_condattr_getclock.c => stdlib/lib_cxa_atexit.c} (68%)
 copy boards/arm/lpc31xx/ea3131/src/lpc31_buttons.c => libs/libc/stdlib/lib_exit.c (80%)
 rename sched/task/task_onexit.c => libs/libc/stdlib/lib_onexit.c (68%)
 delete mode 100644 libs/libxx/libxx.hxx
 delete mode 100644 libs/libxx/libxx_cxa_atexit.cxx
 delete mode 100644 sched/task/task_atexit.c


[incubator-nuttx] 02/03: sched: Remove SCHED_ATEXIT / SCHED_ONEXIT

Posted by xi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git

commit a54c3d13f97aedb17e2085cc731b1cc263d6fe82
Author: Ville Juven <vi...@unikie.com>
AuthorDate: Fri May 6 14:40:37 2022 +0300

    sched: Remove SCHED_ATEXIT / SCHED_ONEXIT
    
    Remove the kernel side implementations altogether. These will be
    replaced by user land implementations.
---
 include/nuttx/sched.h               |  48 ------------
 include/sys/syscall_lookup.h        |   8 --
 libs/libc/pthread/pthread_cleanup.c |   7 +-
 libs/libxx/Makefile                 |   2 -
 libs/libxx/libxx_cxa_atexit.cxx     | 130 --------------------------------
 sched/Kconfig                       |  39 ----------
 sched/task/Make.defs                |   8 --
 sched/task/task_atexit.c            | 133 ---------------------------------
 sched/task/task_exithook.c          | 143 ------------------------------------
 sched/task/task_onexit.c            | 115 -----------------------------
 syscall/syscall.csv                 |   2 -
 11 files changed, 1 insertion(+), 634 deletions(-)

diff --git a/include/nuttx/sched.h b/include/nuttx/sched.h
index 468b32dea3..9738724487 100644
--- a/include/nuttx/sched.h
+++ b/include/nuttx/sched.h
@@ -172,18 +172,6 @@
 #  define _SCHED_ERRVAL(r)           (-errno)
 #endif
 
-/* The number of callback can be saved */
-
-#if defined(CONFIG_SCHED_ONEXIT_MAX)
-#  define CONFIG_SCHED_EXIT_MAX CONFIG_SCHED_ONEXIT_MAX
-#elif defined(CONFIG_SCHED_ATEXIT_MAX)
-#  define CONFIG_SCHED_EXIT_MAX CONFIG_SCHED_ATEXIT_MAX
-#endif
-
-#if defined(CONFIG_SCHED_EXIT_MAX) && CONFIG_SCHED_EXIT_MAX < 1
-#  error "CONFIG_SCHED_EXIT_MAX < 1"
-#endif
-
 #ifdef CONFIG_DEBUG_TCBINFO
 #  define TCB_PID_OFF                offsetof(struct tcb_s, pid)
 #  define TCB_STATE_OFF              offsetof(struct tcb_s, task_state)
@@ -273,18 +261,6 @@ typedef union entry_u entry_t;
 typedef CODE void (*starthook_t)(FAR void *arg);
 #endif
 
-/* These are the types of the functions that are executed with exit() is
- * called (if registered via atexit() on on_exit()).
- */
-
-#ifdef CONFIG_SCHED_ATEXIT
-typedef CODE void (*atexitfunc_t)(void);
-#endif
-
-#ifdef CONFIG_SCHED_ONEXIT
-typedef CODE void (*onexitfunc_t)(int exitcode, FAR void *arg);
-#endif
-
 /* struct sporadic_s ********************************************************/
 
 #ifdef CONFIG_SCHED_SPORADIC
@@ -392,24 +368,6 @@ struct stackinfo_s
                                          /* from the stack.                     */
 };
 
-/* struct exitinfo_s ********************************************************/
-
-struct exitinfo_s
-{
-  union
-  {
-#ifdef CONFIG_SCHED_ATEXIT
-    atexitfunc_t at;
-#endif
-#ifdef CONFIG_SCHED_ONEXIT
-    onexitfunc_t on;
-#endif
-  } func;
-#ifdef CONFIG_SCHED_ONEXIT
-  FAR void *arg;
-#endif
-};
-
 /* struct task_group_s ******************************************************/
 
 /* All threads created by pthread_create belong in the same task group (along
@@ -468,12 +426,6 @@ struct task_group_s
   FAR pid_t *tg_members;            /* Members of the group                     */
 #endif
 
-  /* [at|on]exit support ****************************************************/
-
-#ifdef CONFIG_SCHED_EXIT_MAX
-  struct exitinfo_s tg_exit[CONFIG_SCHED_EXIT_MAX];
-#endif
-
 #ifdef CONFIG_BINFMT_LOADABLE
   /* Loadable module support ************************************************/
 
diff --git a/include/sys/syscall_lookup.h b/include/sys/syscall_lookup.h
index 6da43cbe55..1df3eda2ce 100644
--- a/include/sys/syscall_lookup.h
+++ b/include/sys/syscall_lookup.h
@@ -116,14 +116,6 @@ SYSCALL_LOOKUP(up_assert,                  2)
   SYSCALL_LOOKUP(vfork,                    0)
 #endif
 
-#ifdef CONFIG_SCHED_ATEXIT
-  SYSCALL_LOOKUP(atexit,                   1)
-#endif
-
-#ifdef CONFIG_SCHED_ONEXIT
-  SYSCALL_LOOKUP(on_exit,                  2)
-#endif
-
 #ifdef CONFIG_SCHED_WAITPID
   SYSCALL_LOOKUP(waitpid,                  3)
 #ifdef CONFIG_SCHED_HAVE_PARENT
diff --git a/libs/libc/pthread/pthread_cleanup.c b/libs/libc/pthread/pthread_cleanup.c
index 6aabcb4a7c..b8aca803ad 100644
--- a/libs/libc/pthread/pthread_cleanup.c
+++ b/libs/libc/pthread/pthread_cleanup.c
@@ -75,12 +75,7 @@ static void pthread_cleanup_pop_tls(FAR struct tls_info_s *tls, int execute)
         {
           FAR struct pthread_cleanup_s *cb;
 
-          /* Yes..  Execute the clean-up routine.
-           *
-           * REVISIT: This is a security problem In the PROTECTED and KERNEL
-           * builds:  We must not call the registered function in supervisor
-           * mode!  See also on_exit() and atexit() callbacks.
-           */
+          /* Yes..  Execute the clean-up routine. */
 
           cb  = &tls->stack[ndx];
           cb->pc_cleaner(cb->pc_arg);
diff --git a/libs/libxx/Makefile b/libs/libxx/Makefile
index 50cf35aaad..aa3d7950ce 100644
--- a/libs/libxx/Makefile
+++ b/libs/libxx/Makefile
@@ -41,8 +41,6 @@ ifeq ($(CONFIG_LIBCXXABI),y)
 include libcxxabi.defs
 endif
 
-CXXSRCS += libxx_cxa_atexit.cxx
-
 # Object Files
 
 AOBJS = $(ASRCS:.S=$(OBJEXT))
diff --git a/libs/libxx/libxx_cxa_atexit.cxx b/libs/libxx/libxx_cxa_atexit.cxx
deleted file mode 100644
index 6f50fa1035..0000000000
--- a/libs/libxx/libxx_cxa_atexit.cxx
+++ /dev/null
@@ -1,130 +0,0 @@
-//***************************************************************************
-// libs/libxx/libxx_eabi_atexit.cxx
-//
-// Licensed to the Apache Software Foundation (ASF) under one or more
-// contributor license agreements.  See the NOTICE file distributed with
-// this work for additional information regarding copyright ownership.  The
-// ASF licenses this file to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance with the
-// License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
-// License for the specific language governing permissions and limitations
-//
-//***************************************************************************
-
-//***************************************************************************
-// Included Files
-//***************************************************************************
-
-#include <nuttx/config.h>
-
-#include <cassert>
-#include <nuttx/lib/lib.h>
-
-#include "libxx.hxx"
-
-//***************************************************************************
-// Pre-processor Definitions
-//***************************************************************************
-
-//***************************************************************************
-// Private Types
-//***************************************************************************
-
-struct __cxa_atexit_s
-{
-  __cxa_exitfunc_t func;
-  FAR void *arg;
-};
-
-//***************************************************************************
-// Private Data
-//***************************************************************************
-
-extern "C"
-{
-  //*************************************************************************
-  // Public Data
-  //*************************************************************************
-
-  FAR void *__dso_handle = &__dso_handle;
-
-  //*************************************************************************
-  // Private Functions
-  //*************************************************************************
-
-  //*************************************************************************
-  // Name: __cxa_callback
-  //
-  // Description:
-  //   This is really just an "adaptor" function that matches the form of
-  //   the __cxa_exitfunc_t to an onexitfunc_t using an allocated structure
-  //   to marshall the call parameters.
-  //
-  //*************************************************************************
-
-#ifdef CONFIG_SCHED_ONEXIT
-  static void __cxa_callback(int exitcode, FAR void *arg)
-  {
-    FAR struct __cxa_atexit_s *alloc = (FAR struct __cxa_atexit_s *)arg;
-    DEBUGASSERT(alloc && alloc->func);
-
-    alloc->func(alloc->arg);
-    lib_free(alloc);
-  }
-#endif
-
-  //*************************************************************************
-  // Public Functions
-  //*************************************************************************
-
-  //*************************************************************************
-  // Name: __cxa_atexit
-  //
-  // Description:
-  //   __cxa_atexit() registers a destructor function to be called by exit().
-  //   On a call to exit(), the registered functions should be called with
-  //   the single argument 'arg'. Destructor functions shall always be
-  //   called in the reverse order to their registration (i.e. the most
-  //   recently registered function shall be called first),
-  //
-  //   If shared libraries were supported, the callbacks should be invoked
-  //   when the shared library is unloaded as well.
-  //
-  // Reference:
-  //   Linux base
-  //
-  //*************************************************************************
-
-  int __cxa_atexit(__cxa_exitfunc_t func, FAR void *arg, FAR void *dso_handle)
-    {
-#ifdef CONFIG_SCHED_ONEXIT
-      // Allocate memory to hold the marshaled __cxa_exitfunc_t call
-      // information.
-
-      FAR struct __cxa_atexit_s *alloc =
-        (FAR struct __cxa_atexit_s *)lib_malloc(sizeof(struct __cxa_atexit_s));
-
-      if (alloc)
-        {
-          // Register the function to be called when the task/thread exists.
-
-          alloc->func = func;
-          alloc->arg  = arg;
-
-          return on_exit(__cxa_callback, alloc);
-        }
-      else
-#endif
-        {
-          // What else can we do?
-
-          return 0;
-        }
-    }
-}
diff --git a/sched/Kconfig b/sched/Kconfig
index f6695534d9..fdf8eb0cbe 100644
--- a/sched/Kconfig
+++ b/sched/Kconfig
@@ -1311,45 +1311,6 @@ config SCHED_STARTHOOK
 		starthook is useful, for example, for setting up automatic
 		configuration of C++ constructors.
 
-config SCHED_ATEXIT
-	bool "Enable atexit() API"
-	default n
-	---help---
-		Enables the atexit() API
-
-config SCHED_ATEXIT_MAX
-	int "Max number of atexit() functions"
-	default 1
-	depends on SCHED_ATEXIT && !SCHED_ONEXIT
-	---help---
-		By default if SCHED_ATEXIT is selected, only a single atexit() function
-		is supported. That number can be increased by defined this setting to
-		the number that you require.
-
-		If both SCHED_ONEXIT and SCHED_ATEXIT are selected, then atexit() is built
-		on top of the on_exit() implementation.  In that case, SCHED_ONEXIT_MAX
-		determines the size of the combined number of atexit(0) and on_exit calls
-		and SCHED_ATEXIT_MAX is not used.
-
-config SCHED_ONEXIT
-	bool "Enable on_exit() API"
-	default n
-	---help---
-		Enables the on_exit() API
-
-config SCHED_ONEXIT_MAX
-	int "Max number of on_exit() functions"
-	default 1
-	depends on SCHED_ONEXIT
-	---help---
-		By default if SCHED_ONEXIT is selected, only a single on_exit() function
-		is supported. That number can be increased by defined this setting to the
-		number that you require.
-
-		If both SCHED_ONEXIT and SCHED_ATEXIT are selected, then atexit() is built
-		on top of the on_exit() implementation.  In that case, SCHED_ONEXIT_MAX
-		determines the size of the combined number of atexit(0) and on_exit calls.
-
 endmenu # RTOS hooks
 
 menu "Signal Configuration"
diff --git a/sched/task/Make.defs b/sched/task/Make.defs
index 406ea35a0b..a3a3f34993 100644
--- a/sched/task/Make.defs
+++ b/sched/task/Make.defs
@@ -53,14 +53,6 @@ ifeq ($(CONFIG_SCHED_STARTHOOK),y)
 CSRCS += task_starthook.c
 endif
 
-ifeq ($(CONFIG_SCHED_ATEXIT),y)
-CSRCS += task_atexit.c
-endif
-
-ifeq ($(CONFIG_SCHED_ONEXIT),y)
-CSRCS += task_onexit.c
-endif
-
 # Include task build support
 
 DEPPATH += --dep-path task
diff --git a/sched/task/task_atexit.c b/sched/task/task_atexit.c
deleted file mode 100644
index c5b7c2b4e5..0000000000
--- a/sched/task/task_atexit.c
+++ /dev/null
@@ -1,133 +0,0 @@
-/****************************************************************************
- * sched/task/task_atexit.c
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.  The
- * ASF licenses this file to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance with the
- * License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
- * License for the specific language governing permissions and limitations
- * under the License.
- *
- ****************************************************************************/
-
-/****************************************************************************
- * Included Files
- ****************************************************************************/
-
-#include <nuttx/config.h>
-
-#include <stdlib.h>
-#include <assert.h>
-#include <unistd.h>
-#include <debug.h>
-#include <errno.h>
-
-#include <nuttx/fs/fs.h>
-
-#include "sched/sched.h"
-#include "task/task.h"
-
-#ifdef CONFIG_SCHED_ATEXIT
-
-/****************************************************************************
- * Private Functions
- ****************************************************************************/
-
-#ifdef CONFIG_SCHED_ONEXIT
-static void exitfunc(int exitcode, FAR void *arg)
-{
-  (*(atexitfunc_t)arg)();
-}
-#endif
-
-/****************************************************************************
- * Public Functions
- ****************************************************************************/
-
-/****************************************************************************
- * Name: atexit
- *
- * Description:
- *    Registers a function to be called at program exit.
- *    The atexit() function registers the given function to be called
- *    at normal process termination, whether via exit or via return from
- *    the program's main().
- *
- *    NOTE: CONFIG_SCHED_ATEXIT must be defined to enable this function
- *
- *    Limitations in the current implementation:
- *
- *      1. Only a single atexit function can be registered unless
- *         CONFIG_SCHED_ATEXIT_MAX defines a larger number.
- *      2. atexit functions are not inherited when a new task is
- *         created.
- *      3. If both SCHED_ONEXIT and SCHED_ATEXIT are selected, then atexit()
- *         is built on top of the on_exit() implementation.  In that case,
- *         CONFIG_SCHED_ONEXIT_MAX determines the size of the combined
- *         number of atexit() and on_exit() calls and SCHED_ATEXIT_MAX is
- *         not used.
- *
- * Input Parameters:
- *   func - A pointer to the function to be called when the task exits.
- *
- * Returned Value:
- *   Zero on success. Non-zero on failure.
- *
- ****************************************************************************/
-
-int atexit(void (*func)(void))
-{
-#if defined(CONFIG_SCHED_ONEXIT)
-  /* atexit is equivalent to on_exit() with no argument (Assuming that the
-   * ABI can handle a callback function that receives more parameters than
-   * it expects).
-   */
-
-  return on_exit(exitfunc, func);
-
-#else
-  FAR struct tcb_s *tcb = this_task();
-  FAR struct task_group_s *group = tcb->group;
-  int index;
-  int ret = ERROR;
-
-  DEBUGASSERT(group);
-
-  /* The following must be atomic */
-
-  if (func)
-    {
-      sched_lock();
-
-      /* Search for the first available slot.  atexit() functions are
-       * registered from lower to higher array indices; they must be called
-       * in the reverse order of registration when task exists, i.e., from
-       * higher to lower indices.
-       */
-
-      for (index = 0; index < CONFIG_SCHED_EXIT_MAX; index++)
-        {
-          if (!group->tg_exit[index].func.at)
-            {
-              group->tg_exit[index].func.at = func;
-              ret = OK;
-              break;
-            }
-        }
-
-      sched_unlock();
-    }
-
-  return ret;
-#endif
-}
-
-#endif /* CONFIG_SCHED_ATEXIT */
diff --git a/sched/task/task_exithook.c b/sched/task/task_exithook.c
index 0955658f5f..0a1cbcbb41 100644
--- a/sched/task/task_exithook.c
+++ b/sched/task/task_exithook.c
@@ -43,126 +43,6 @@
  * Private Functions
  ****************************************************************************/
 
-/****************************************************************************
- * Name: nxtask_atexit
- *
- * Description:
- *   Call any registered atexit function(s)
- *
- ****************************************************************************/
-
-#if defined(CONFIG_SCHED_ATEXIT) && !defined(CONFIG_SCHED_ONEXIT)
-static inline void nxtask_atexit(FAR struct tcb_s *tcb)
-{
-  FAR struct task_group_s *group = tcb->group;
-
-  /* Make sure that we have not already left the group.  Only the final
-   * exiting thread in the task group should trigger the atexit()
-   * callbacks.
-   *
-   * REVISIT: This is a security problem In the PROTECTED and KERNEL builds:
-   * We must not call the registered function in supervisor mode!  See also
-   * on_exit() and pthread_cleanup_pop() callbacks.
-   *
-   * REVISIT:  In the case of task_delete(), the callback would execute in
-   * the context the caller of task_delete() cancel, not in the context of
-   * the exiting task (or process).
-   */
-
-  if (group && group->tg_nmembers == 1)
-    {
-      int index;
-
-      /* Call each atexit function in reverse order of registration atexit()
-       * functions are registered from lower to higher array indices; they
-       * must be called in the reverse order of registration when the task
-       * group exits, i.e., from higher to lower indices.
-       */
-
-      for (index = CONFIG_SCHED_EXIT_MAX - 1; index >= 0; index--)
-        {
-          if (group->tg_exit[index].func.at)
-            {
-              atexitfunc_t func;
-
-              /* Nullify the atexit function to prevent its reuse. */
-
-              func = group->tg_exit[index].func.at;
-              group->tg_exit[index].func.at = NULL;
-
-              /* Call the atexit function */
-
-              (*func)();
-            }
-        }
-    }
-}
-#else
-#  define nxtask_atexit(tcb)
-#endif
-
-/****************************************************************************
- * Name: nxtask_onexit
- *
- * Description:
- *   Call any registered on_exit function(s)
- *
- ****************************************************************************/
-
-#ifdef CONFIG_SCHED_ONEXIT
-static inline void nxtask_onexit(FAR struct tcb_s *tcb, int status)
-{
-  FAR struct task_group_s *group = tcb->group;
-
-  /* Make sure that we have not already left the group.  Only the final
-   * exiting thread in the task group should trigger the atexit()
-   * callbacks.
-   *
-   * REVISIT: This is a security problem In the PROTECTED and KERNEL builds:
-   * We must not call the registered function in supervisor mode!  See also
-   * atexit() and pthread_cleanup_pop() callbacks.
-   *
-   * REVISIT:  In the case of task_delete(), the callback would execute in
-   * he context the caller of task_delete() cancel, not in the context of
-   * the exiting task (or process).
-   */
-
-  if (group && group->tg_nmembers == 1)
-    {
-      int index;
-
-      /* Call each on_exit function in reverse order of registration.
-       * on_exit() functions are registered from lower to higher array
-       * indices; they must be called in the reverse order of registration
-       * when the task group exits, i.e., from higher to lower indices.
-       */
-
-      for (index = CONFIG_SCHED_EXIT_MAX - 1; index >= 0; index--)
-        {
-          if (group->tg_exit[index].func.on)
-            {
-              onexitfunc_t func;
-              FAR void    *arg;
-
-              /* Nullify the on_exit function to prevent its reuse. */
-
-              func = group->tg_exit[index].func.on;
-              arg  = group->tg_exit[index].arg;
-
-              group->tg_exit[index].func.on = NULL;
-              group->tg_exit[index].arg     = NULL;
-
-              /* Call the on_exit function */
-
-              (*func)(status, arg);
-            }
-        }
-    }
-}
-#else
-#  define nxtask_onexit(tcb,status)
-#endif
-
 /****************************************************************************
  * Name: nxtask_exitstatus
  *
@@ -579,31 +459,8 @@ void nxtask_exithook(FAR struct tcb_s *tcb, int status, bool nonblocking)
   tcb->cpcount = 0;
 #endif
 
-  /* If exit function(s) were registered, call them now before we do any un-
-   * initialization.
-   *
-   * NOTES:
-   *
-   * 1. In the case of task_delete(), the exit function will *not* be called
-   *    on the thread execution of the task being deleted!  That is probably
-   *    a bug.
-   * 2. We cannot call the exit functions if nonblocking is requested:  These
-   *    functions might block.
-   * 3. This function will only be called with non-blocking == true
-   *    only when called through _exit(). _exit() behaviors requires that
-   *    the exit functions *not* be called.
-   */
-
   if (!nonblocking)
     {
-#if defined(CONFIG_SCHED_ATEXIT) || defined(CONFIG_SCHED_ONEXIT)
-      nxtask_atexit(tcb);
-
-      /* Call any registered on_exit function(s) */
-
-      nxtask_onexit(tcb, status);
-#endif
-
       /* If this is the last thread in the group, then flush all streams
        * (File descriptors will be closed when the TCB is deallocated).
        *
diff --git a/sched/task/task_onexit.c b/sched/task/task_onexit.c
deleted file mode 100644
index 2e11673fe6..0000000000
--- a/sched/task/task_onexit.c
+++ /dev/null
@@ -1,115 +0,0 @@
-/****************************************************************************
- * sched/task/task_onexit.c
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.  The
- * ASF licenses this file to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance with the
- * License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
- * License for the specific language governing permissions and limitations
- * under the License.
- *
- ****************************************************************************/
-
-/****************************************************************************
- * Included Files
- ****************************************************************************/
-
-#include <nuttx/config.h>
-
-#include <stdlib.h>
-#include <assert.h>
-#include <unistd.h>
-#include <debug.h>
-#include <errno.h>
-
-#include <nuttx/fs/fs.h>
-
-#include "sched/sched.h"
-#include "task/task.h"
-
-#ifdef CONFIG_SCHED_ONEXIT
-
-/****************************************************************************
- * Public Functions
- ****************************************************************************/
-
-/****************************************************************************
- * Name: on_exit
- *
- * Description:
- *    Registers a function to be called at program exit.
- *    The on_exit() function registers the given function to be called
- *    at normal process termination, whether via exit or via return from
- *    the program's main(). The function is passed the status argument
- *    given to the last call to exit and the arg argument from on_exit().
- *
- *    NOTE 1: This function comes from SunOS 4, but is also present in
- *    libc4, libc5 and glibc. It no longer occurs in Solaris (SunOS 5).
- *    Avoid this function, and use the standard atexit() instead.
- *
- *    NOTE 2: CONFIG_SCHED_ONEXIT must be defined to enable this function
- *
- *    Limitations in the current implementation:
- *
- *      1. Only a single on_exit function can be registered unless
- *         CONFIG_SCHED_ONEXIT_MAX defines a larger number.
- *      2. on_exit functions are not inherited when a new task is
- *         created.
- *
- * Input Parameters:
- *   func - A pointer to the function to be called when the task exits.
- *   arg -  An argument that will be provided to the on_exit() function when
- *          the task exits.
- *
- * Returned Value:
- *   Zero on success. Non-zero on failure.
- *
- ****************************************************************************/
-
-int on_exit(CODE void (*func)(int, FAR void *), FAR void *arg)
-{
-  FAR struct tcb_s *tcb = this_task();
-  FAR struct task_group_s *group = tcb->group;
-  int index;
-  int ret = ENOSPC;
-
-  DEBUGASSERT(group);
-
-  /* The following must be atomic */
-
-  if (func)
-    {
-      sched_lock();
-
-      /* Search for the first available slot.  on_exit() functions are
-       * registered from lower to higher array indices; they must be called
-       * in the reverse order of registration when task exists, i.e.,
-       * from higher to lower indices.
-       */
-
-      for (index = 0; index < CONFIG_SCHED_EXIT_MAX; index++)
-        {
-          if (!group->tg_exit[index].func.on)
-            {
-              group->tg_exit[index].func.on = func;
-              group->tg_exit[index].arg     = arg;
-              ret = OK;
-              break;
-            }
-        }
-
-      sched_unlock();
-    }
-
-  return ret;
-}
-
-#endif /* CONFIG_SCHED_ONEXIT */
diff --git a/syscall/syscall.csv b/syscall/syscall.csv
index 0b903a42c0..88d8c128a1 100644
--- a/syscall/syscall.csv
+++ b/syscall/syscall.csv
@@ -6,7 +6,6 @@
 "aio_read","aio.h","defined(CONFIG_FS_AIO)","int","FAR struct aiocb *"
 "aio_write","aio.h","defined(CONFIG_FS_AIO)","int","FAR struct aiocb *"
 "arc4random_buf","stdlib.h","defined(CONFIG_CRYPTO_RANDOM_POOL)","void","FAR void *","size_t"
-"atexit","stdlib.h","defined(CONFIG_SCHED_ATEXIT)","int","void (*)(void)"
 "bind","sys/socket.h","defined(CONFIG_NET)","int","int","FAR const struct sockaddr *","socklen_t"
 "boardctl","sys/boardctl.h","defined(CONFIG_BOARDCTL)","int","unsigned int","uintptr_t"
 "chmod","sys/stat.h","","int","FAR const char *","mode_t"
@@ -78,7 +77,6 @@
 "nx_vsyslog","nuttx/syslog/syslog.h","","int","int","FAR const IPTR char *","FAR va_list *"
 "nxsched_get_stackinfo","nuttx/sched.h","","int","pid_t","FAR struct stackinfo_s *"
 "nxsched_get_streams","nuttx/sched.h","defined(CONFIG_FILE_STREAM)","FAR struct streamlist *"
-"on_exit","stdlib.h","defined(CONFIG_SCHED_ONEXIT)","int","CODE void (*)(int, FAR void *)","FAR void *"
 "open","fcntl.h","","int","FAR const char *","int","...","mode_t"
 "opendir","dirent.h","","FAR DIR *","FAR const char *"
 "pgalloc", "nuttx/arch.h", "defined(CONFIG_BUILD_KERNEL)", "uintptr_t", "uintptr_t", "unsigned int"


[incubator-nuttx] 01/03: libc: Implement exit, atexit, on_exit and cxa_exit on the user side

Posted by xi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git

commit 622677d4a1b3a9f20234571fafdceb7b98fe1425
Author: Ville Juven <vi...@unikie.com>
AuthorDate: Mon May 2 15:15:06 2022 +0300

    libc: Implement exit, atexit, on_exit and cxa_exit on the user side
    
    For CONFIG_BUILD_KERNEL using the sched/task/task_exithook implementation
    will just not work. It calls user code with kernel privileges which is
    a bit of a security issue.
---
 include/nuttx/atexit.h                             | 118 +++++++++++
 include/nuttx/tls.h                                |   5 +
 libs/libc/machine/arm/aeabi_atexit.c               |   9 +-
 libs/libc/stdlib/Kconfig                           |   7 +
 libs/libc/stdlib/Make.defs                         |   6 +-
 libs/libc/stdlib/lib_atexit.c                      | 221 +++++++++++++++++++++
 .../arm/aeabi_atexit.c => stdlib/lib_cxa_atexit.c} |  36 ++--
 libs/libc/stdlib/{lib__Exit.c => lib_exit.c}       |  27 ++-
 .../arm/aeabi_atexit.c => stdlib/lib_onexit.c}     |  48 +++--
 libs/libc/unistd/lib_sysconf.c                     |   8 +-
 libs/libxx/libxx.hxx                               |  49 -----
 sched/task/exit.c                                  |  30 +--
 12 files changed, 441 insertions(+), 123 deletions(-)

diff --git a/include/nuttx/atexit.h b/include/nuttx/atexit.h
new file mode 100644
index 0000000000..ad511290b5
--- /dev/null
+++ b/include/nuttx/atexit.h
@@ -0,0 +1,118 @@
+/****************************************************************************
+ * include/nuttx/atexit.h
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+#ifndef __INCLUDE_NUTTX_ATEXIT_H
+#define __INCLUDE_NUTTX_ATEXIT_H
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+#include <stdlib.h>
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+/* Amount of exit functions */
+
+#define ATEXIT_MAX (CONFIG_LIBC_MAX_EXITFUNS)
+
+/****************************************************************************
+ * Public Types
+ ****************************************************************************/
+
+enum atexit_type_e
+{
+  ATTYPE_NONE,
+  ATTYPE_ATEXIT,
+  ATTYPE_ONEXIT,
+  ATTYPE_CXA
+};
+
+struct atexit_s
+{
+  int         type;
+  CODE void (*func)(void);
+  FAR void   *arg;
+};
+
+struct atexit_list_s
+{
+  int             nfuncs;
+  struct atexit_s funcs[ATEXIT_MAX];
+};
+
+/****************************************************************************
+ * Public Function Prototypes
+ ****************************************************************************/
+
+#if defined(__cplusplus)
+extern "C"
+{
+#endif
+
+#if CONFIG_LIBC_MAX_EXITFUNS > 0
+
+/****************************************************************************
+ * Name: atexit_register
+ *
+ * Description:
+ *   atexit_register registers a function function to be called by exit().
+ *
+ * Input Parameters:
+ *   type - Type of exit function. Available types in atexit_type_e.
+ *   func - Function to be called on exit.
+ *   arg  - Optional argument to be passed to function on exit.
+ *   dso  - Dso handle, called when shared library is unloaded.
+ *
+ * Returned value:
+ *   OK  on success; ERROR on failure
+ *
+ ****************************************************************************/
+
+int atexit_register(int type, CODE void (*func)(void), FAR void *arg,
+                    FAR void *dso);
+
+/****************************************************************************
+ * Name: atexit_call_exitfuncs
+ *
+ * Description:
+ *   Execute the registered exit functions. Call this in exit().
+ *
+ * Input Parameters:
+ *   status - Process exit status code.
+ *
+ * Returned value:
+ *   None
+ *
+ ****************************************************************************/
+
+void atexit_call_exitfuncs(int status);
+#else
+#  define atexit_register(type, func, arg, dso) (0)
+#  define atexit_call_exitfuncs(status)
+#endif /* CONFIG_LIBC_MAX_EXITFUNS */
+
+#if defined(__cplusplus)
+}
+#endif
+#endif /* __INCLUDE_NUTTX_ATEXIT_H */
diff --git a/include/nuttx/tls.h b/include/nuttx/tls.h
index de4cbcfe14..27e031e3e1 100644
--- a/include/nuttx/tls.h
+++ b/include/nuttx/tls.h
@@ -27,6 +27,8 @@
 
 #include <nuttx/config.h>
 
+#include <nuttx/atexit.h>
+
 #include <sys/types.h>
 #include <pthread.h>
 
@@ -132,6 +134,9 @@ struct task_info_s
   char            ta_domain[NAME_MAX]; /* Current domain for gettext */
 #  endif
 #endif
+#if CONFIG_LIBC_MAX_EXITFUNS > 0
+  struct atexit_list_s ta_exit; /* Exit functions */
+#endif
 };
 
 /* struct pthread_cleanup_s *************************************************/
diff --git a/libs/libc/machine/arm/aeabi_atexit.c b/libs/libc/machine/arm/aeabi_atexit.c
index 4d28606d44..9b27d1f877 100644
--- a/libs/libc/machine/arm/aeabi_atexit.c
+++ b/libs/libc/machine/arm/aeabi_atexit.c
@@ -24,11 +24,7 @@
 
 #include <nuttx/compiler.h>
 
-/****************************************************************************
- * Public Function Prototypes
- ****************************************************************************/
-
-int __cxa_atexit(void (*func)(void *), void *object, void *dso_handle);
+#include <nuttx/atexit.h>
 
 /****************************************************************************
  * Public Functions
@@ -50,5 +46,6 @@ int weak_function __aeabi_atexit(void *object,
                                  void (*func)(void *),
                                  void *dso_handle)
 {
-  return __cxa_atexit(func, object, dso_handle);
+  return atexit_register(ATTYPE_CXA, (void (*)(void))func, object,
+                         dso_handle);
 }
diff --git a/libs/libc/stdlib/Kconfig b/libs/libc/stdlib/Kconfig
index b9125f8848..f963f30dc6 100644
--- a/libs/libc/stdlib/Kconfig
+++ b/libs/libc/stdlib/Kconfig
@@ -39,4 +39,11 @@ config LIBC_MAX_TMPFILE
 		maximum size of that last filename.  This size is the size of the full
 		file path.
 
+config LIBC_MAX_EXITFUNS
+	int "Maximum amount of exit functions"
+	default 0
+		---help---
+		Configure the amount of exit functions for atexit/on_exit. The ANSI
+		default is 32, but most likely we don't need as many.
+
 endmenu # stdlib Options
diff --git a/libs/libc/stdlib/Make.defs b/libs/libc/stdlib/Make.defs
index 4b5dabf2d9..0c9b40b353 100644
--- a/libs/libc/stdlib/Make.defs
+++ b/libs/libc/stdlib/Make.defs
@@ -21,13 +21,17 @@
 # Add the stdlib C files to the build
 
 CSRCS += lib_abs.c lib_abort.c lib_atof.c lib_atoi.c lib_getprogname.c
-CSRCS += lib_atol.c lib_atoll.c lib_div.c lib_ldiv.c lib_lldiv.c lib__Exit.c
+CSRCS += lib_atol.c lib_atoll.c lib_div.c lib_ldiv.c lib_lldiv.c lib_exit.c
 CSRCS += lib_itoa.c lib_labs.c lib_llabs.c lib_realpath.c lib_bsearch.c
 CSRCS += lib_rand.c lib_qsort.c lib_srand.c lib_strtol.c
 CSRCS += lib_strtoll.c lib_strtoul.c lib_strtoull.c lib_strtod.c lib_strtof.c
 CSRCS += lib_strtold.c lib_checkbase.c lib_mktemp.c lib_mkstemp.c lib_mkdtemp.c
 CSRCS += lib_aligned_alloc.c lib_posix_memalign.c lib_valloc.c
 
+ifneq ($(CONFIG_LIBC_MAX_EXITFUNS),0)
+CSRCS += lib_atexit.c lib_cxa_atexit.c lib_onexit.c
+endif
+
 ifeq ($(CONFIG_LIBC_WCHAR),y)
 CSRCS += lib_mblen.c lib_mbtowc.c lib_wctomb.c
 CSRCS += lib_mbstowcs.c lib_wcstombs.c
diff --git a/libs/libc/stdlib/lib_atexit.c b/libs/libc/stdlib/lib_atexit.c
new file mode 100644
index 0000000000..7f3dcaefc4
--- /dev/null
+++ b/libs/libc/stdlib/lib_atexit.c
@@ -0,0 +1,221 @@
+/****************************************************************************
+ * libs/libc/stdlib/lib_atexit.c
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <stdlib.h>
+
+#include <nuttx/atexit.h>
+#include <nuttx/semaphore.h>
+#include <nuttx/tls.h>
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: get_exitfuncs
+ *
+ * Description:
+ *    Obtain the list of exit functions.
+ *
+ * Input Parameters:
+ *   None
+ *
+ * Returned Value:
+ *   Pointer to the list of exit functions.
+ *
+ ****************************************************************************/
+
+static FAR struct atexit_list_s * get_exitfuncs(void)
+{
+  FAR struct task_info_s *info;
+
+  info = task_get_info();
+  return &info->ta_exit;
+}
+
+/****************************************************************************
+ * Name: exitfunc_lock
+ *
+ * Description:
+ *    Obtain the exit function lock.
+ *
+ * Returned Value:
+ *   OK on success, or negated errno on failure
+ *
+ ****************************************************************************/
+
+static int exitfunc_lock(void)
+{
+  FAR struct task_info_s *info = task_get_info();
+  int ret = _SEM_WAIT(&info->ta_sem);
+
+  if (ret < 0)
+    {
+      ret = _SEM_ERRVAL(ret);
+    }
+
+  return ret;
+}
+
+/****************************************************************************
+ * Name: exitfunc_unlock
+ *
+ * Description:
+ *    Release exit function lock .
+ *
+ ****************************************************************************/
+
+static void exitfunc_unlock(void)
+{
+  FAR struct task_info_s *info = task_get_info();
+
+  _SEM_POST(&info->ta_sem);
+}
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: atexit
+ *
+ * Description:
+ *    Registers a function to be called at program exit.
+ *    The atexit() function registers the given function to be called
+ *    at normal process termination, whether via exit or via return from
+ *    the program's main().
+ *
+ *    Limitations in the current implementation:
+ *
+ *      1. Only a single atexit function can be registered unless
+ *         CONFIG_LIBC_MAX_EXITFUNS defines a larger number.
+ *      2. atexit functions are not inherited when a new task is
+ *         created.
+ *
+ * Input Parameters:
+ *   func - A pointer to the function to be called when the task exits.
+ *
+ * Returned Value:
+ *   Zero on success. Non-zero on failure.
+ *
+ ****************************************************************************/
+
+int atexit(CODE void (*func)(void))
+{
+  return atexit_register(ATTYPE_ATEXIT, func, NULL, NULL);
+}
+
+int atexit_register(int type, CODE void (*func)(void), FAR void *arg,
+                    FAR void *dso)
+{
+  FAR struct atexit_list_s *aehead;
+  int                       idx;
+  int                       ret = ERROR;
+
+  /* REVISIT: Missing logic */
+
+  UNUSED(dso);
+
+  /* The following must be atomic */
+
+  aehead = get_exitfuncs();
+
+  if (func)
+    {
+      ret = exitfunc_lock();
+      if (ret < 0)
+        {
+          return ret;
+        }
+
+      if ((idx = aehead->nfuncs) < ATEXIT_MAX)
+        {
+          aehead->funcs[idx].type = type;
+          aehead->funcs[idx].func = func;
+          aehead->funcs[idx].arg  = arg;
+          aehead->nfuncs++;
+          ret = OK;
+        }
+      else
+        {
+          ret = ERROR;
+        }
+
+      exitfunc_unlock();
+    }
+
+  return ret;
+}
+
+void atexit_call_exitfuncs(int status)
+{
+  FAR struct atexit_list_s *aehead;
+  CODE void               (*func)(void);
+  FAR void                 *arg;
+  int                       idx;
+  int                       type;
+
+  /* Call exit functions in reverse order */
+
+  aehead = get_exitfuncs();
+
+  for (idx = aehead->nfuncs - 1; idx >= 0; idx--)
+    {
+      /* Remove the function to prevent recursive call to it */
+
+      type = aehead->funcs[idx].type;
+
+      func = aehead->funcs[idx].func;
+      arg  = aehead->funcs[idx].arg;
+
+      aehead->funcs[idx].func = NULL;
+      aehead->funcs[idx].arg  = NULL;
+
+      if (!func)
+        {
+          continue;
+        }
+
+      /* Call the atexit/on_exit/cxa_atexit() function */
+
+      if (type == ATTYPE_ATEXIT)
+        {
+          (*func)();
+        }
+      else if (type == ATTYPE_ONEXIT)
+        {
+          (*((CODE void (*)(int, FAR void *))func))(status, arg);
+        }
+      else if (type == ATTYPE_CXA)
+        {
+          (*((CODE void (*)(FAR void *))func))(arg);
+        }
+    }
+}
diff --git a/libs/libc/machine/arm/aeabi_atexit.c b/libs/libc/stdlib/lib_cxa_atexit.c
similarity index 63%
copy from libs/libc/machine/arm/aeabi_atexit.c
copy to libs/libc/stdlib/lib_cxa_atexit.c
index 4d28606d44..3e68eedfb5 100644
--- a/libs/libc/machine/arm/aeabi_atexit.c
+++ b/libs/libc/stdlib/lib_cxa_atexit.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * libs/libc/machine/arm/aeabi_atexit.c
+ * libs/libc/stdlib/lib_cxa_atexit.c
  *
  * Licensed to the Apache Software Foundation (ASF) under one or more
  * contributor license agreements.  See the NOTICE file distributed with
@@ -22,33 +22,35 @@
  * Included Files
  ****************************************************************************/
 
-#include <nuttx/compiler.h>
+#include <nuttx/config.h>
 
-/****************************************************************************
- * Public Function Prototypes
- ****************************************************************************/
-
-int __cxa_atexit(void (*func)(void *), void *object, void *dso_handle);
+#include <nuttx/atexit.h>
 
 /****************************************************************************
  * Public Functions
  ****************************************************************************/
 
 /****************************************************************************
- * Name: __aeabi_atexit
+ * Name: __cxa_atexit
  *
  * Description:
- *   Registers static object destructors.  Normally atexit(f) should call
- *   __aeabi_atexit (NULL, f, NULL).  But in the usage model here, static
- *   constructors are initialized at power up and are never destroyed
- *   because they have global scope and must persist for as long as the
- *   embedded device is powered on.
+ *   __cxa_atexit() registers a destructor function to be called by exit().
+ *   On a call to exit(), the registered functions should be called with
+ *   the single argument 'arg'. Destructor functions shall always be
+ *   called in the reverse order to their registration (i.e. the most
+ *   recently registered function shall be called first),
+ *
+ *   If shared libraries were supported, the callbacks should be invoked
+ *   when the shared library is unloaded as well.
+ *
+ * Reference:
+ *   Linux base
  *
  ****************************************************************************/
 
-int weak_function __aeabi_atexit(void *object,
-                                 void (*func)(void *),
-                                 void *dso_handle)
+int __cxa_atexit(CODE void (*func)(FAR void *), FAR void *arg,
+                 FAR void *dso_handle)
 {
-  return __cxa_atexit(func, object, dso_handle);
+  return atexit_register(ATTYPE_CXA, (CODE void (*)(void))func, arg,
+                         dso_handle);
 }
diff --git a/libs/libc/stdlib/lib__Exit.c b/libs/libc/stdlib/lib_exit.c
similarity index 67%
rename from libs/libc/stdlib/lib__Exit.c
rename to libs/libc/stdlib/lib_exit.c
index 557dfa8b36..73f669a790 100644
--- a/libs/libc/stdlib/lib__Exit.c
+++ b/libs/libc/stdlib/lib_exit.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * libs/libc/stdlib/lib__Exit.c
+ * libs/libc/stdlib/lib_exit.c
  *
  * Licensed to the Apache Software Foundation (ASF) under one or more
  * contributor license agreements.  See the NOTICE file distributed with
@@ -22,13 +22,38 @@
  * Included Files
  ****************************************************************************/
 
+#include <nuttx/config.h>
+
+#include <nuttx/atexit.h>
+#include <nuttx/compiler.h>
+
 #include <stdlib.h>
 #include <unistd.h>
 
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+/****************************************************************************
+ * Public Data
+ ****************************************************************************/
+
+extern FAR void *__dso_handle weak_data;
+FAR void *__dso_handle = &__dso_handle;
+
 /****************************************************************************
  * Public Functions
  ****************************************************************************/
 
+void exit(int status)
+{
+  atexit_call_exitfuncs(status);
+
+  /* REVISIT: Need to flush files and streams */
+
+  _exit(status);
+}
+
 void _Exit(int status)
 {
   _exit(status);
diff --git a/libs/libc/machine/arm/aeabi_atexit.c b/libs/libc/stdlib/lib_onexit.c
similarity index 52%
copy from libs/libc/machine/arm/aeabi_atexit.c
copy to libs/libc/stdlib/lib_onexit.c
index 4d28606d44..f3a34d9827 100644
--- a/libs/libc/machine/arm/aeabi_atexit.c
+++ b/libs/libc/stdlib/lib_onexit.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * libs/libc/machine/arm/aeabi_atexit.c
+ * libs/libc/stdlib/lib_onexit.c
  *
  * Licensed to the Apache Software Foundation (ASF) under one or more
  * contributor license agreements.  See the NOTICE file distributed with
@@ -22,33 +22,47 @@
  * Included Files
  ****************************************************************************/
 
-#include <nuttx/compiler.h>
+#include <nuttx/config.h>
 
-/****************************************************************************
- * Public Function Prototypes
- ****************************************************************************/
-
-int __cxa_atexit(void (*func)(void *), void *object, void *dso_handle);
+#include <nuttx/atexit.h>
 
 /****************************************************************************
  * Public Functions
  ****************************************************************************/
 
 /****************************************************************************
- * Name: __aeabi_atexit
+ * Name: on_exit
  *
  * Description:
- *   Registers static object destructors.  Normally atexit(f) should call
- *   __aeabi_atexit (NULL, f, NULL).  But in the usage model here, static
- *   constructors are initialized at power up and are never destroyed
- *   because they have global scope and must persist for as long as the
- *   embedded device is powered on.
+ *    Registers a function to be called at program exit.
+ *    The on_exit() function registers the given function to be called
+ *    at normal process termination, whether via exit or via return from
+ *    the program's main(). The function is passed the status argument
+ *    given to the last call to exit and the arg argument from on_exit().
+ *
+ *    NOTE 1: This function comes from SunOS 4, but is also present in
+ *    libc4, libc5 and glibc. It no longer occurs in Solaris (SunOS 5).
+ *    Avoid this function, and use the standard atexit() instead.
+ *
+ *    Limitations in the current implementation:
+ *
+ *      1. Only a single on_exit function can be registered unless
+ *         CONFIG_LIBC_MAX_EXITFUNS defines a larger number.
+ *      2. on_exit functions are not inherited when a new task is
+ *         created.
+ *
+ * Input Parameters:
+ *   func - A pointer to the function to be called when the task exits.
+ *   arg -  An argument that will be provided to the on_exit() function when
+ *          the task exits.
+ *
+ * Returned Value:
+ *   Zero on success. Non-zero on failure.
  *
  ****************************************************************************/
 
-int weak_function __aeabi_atexit(void *object,
-                                 void (*func)(void *),
-                                 void *dso_handle)
+int on_exit(CODE void (*func)(int, FAR void *), FAR void *arg)
 {
-  return __cxa_atexit(func, object, dso_handle);
+  return atexit_register(ATTYPE_ONEXIT, (CODE void (*)(void))func, arg,
+                         NULL);
 }
diff --git a/libs/libc/unistd/lib_sysconf.c b/libs/libc/unistd/lib_sysconf.c
index ee5fd2b35c..6a141a2e52 100644
--- a/libs/libc/unistd/lib_sysconf.c
+++ b/libs/libc/unistd/lib_sysconf.c
@@ -24,6 +24,8 @@
 
 #include <nuttx/config.h>
 
+#include <nuttx/atexit.h>
+
 #include <unistd.h>
 #include <sched.h>
 #include <errno.h>
@@ -214,11 +216,7 @@ long sysconf(int name)
         return OPEN_MAX;
 
       case _SC_ATEXIT_MAX:
-#ifdef CONFIG_SCHED_EXIT_MAX
-        return CONFIG_SCHED_EXIT_MAX;
-#else
-        return 0;
-#endif
+        return ATEXIT_MAX;
 
       case _SC_NPROCESSORS_CONF:
       case _SC_NPROCESSORS_ONLN:
diff --git a/libs/libxx/libxx.hxx b/libs/libxx/libxx.hxx
deleted file mode 100644
index 9dfd110fdb..0000000000
--- a/libs/libxx/libxx.hxx
+++ /dev/null
@@ -1,49 +0,0 @@
-//***************************************************************************
-// libs/libxx/libxx.hxx
-//
-// Licensed to the Apache Software Foundation (ASF) under one or more
-// contributor license agreements.  See the NOTICE file distributed with
-// this work for additional information regarding copyright ownership.  The
-// ASF licenses this file to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance with the
-// License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
-// License for the specific language governing permissions and limitations
-//
-//***************************************************************************
-
-#ifndef __LIBS_LIBXX_LIBXX_HXX
-#define __LIBS_LIBXX_LIBXX_HXX 1
-
-//***************************************************************************
-// Included Files
-//***************************************************************************
-
-#include <nuttx/config.h>
-
-#include <nuttx/compiler.h>
-
-//***************************************************************************
-// Public Types
-//***************************************************************************/
-
-typedef CODE void (*__cxa_exitfunc_t)(void *arg);
-
-//***************************************************************************
-// Public Data
-//***************************************************************************
-
-extern "C" FAR void *__dso_handle weak_data;
-
-//***************************************************************************
-// Public Function Prototypes
-//***************************************************************************
-
-extern "C" int __cxa_atexit(__cxa_exitfunc_t func, void *arg, void *dso_handle);
-
-#endif // __LIBS_LIBXX_LIBXX_HXX
diff --git a/sched/task/exit.c b/sched/task/exit.c
index 97d0b7a05b..0834d87e95 100644
--- a/sched/task/exit.c
+++ b/sched/task/exit.c
@@ -52,25 +52,6 @@
  ****************************************************************************/
 
 void _exit(int status)
-{
-  up_exit(status);
-}
-
-/****************************************************************************
- * Name: exit
- *
- * Description:
- *   The exit() function causes normal process termination and the value of
- *   status & 0377 to be returned to the parent.
- *
- *   All functions registered with atexit() and on_exit() are called, in the
- *   reverse order of their registration.
- *
- *   All open streams are flushed and closed.
- *
- ****************************************************************************/
-
-void exit(int status)
 {
   FAR struct tcb_s *tcb = this_task();
 
@@ -94,17 +75,12 @@ void exit(int status)
 #endif
 
   /* Perform common task termination logic.  This will get called again later
-   * through logic kicked off by _exit().  However, we need to call it before
-   * calling _exit() in order to handle atexit() and on_exit() callbacks and
+   * through logic kicked off by up_exit().  However, we need to call it here
    * so that we can flush buffered I/O (both of which may required
-   * suspending).
+   * suspending). This will be fixed later when I/O flush is moved to libc.
    */
 
   nxtask_exithook(tcb, status, false);
 
-  /* Then "really" exit.  Only the lower 8 bits of the exit status are
-   * used.
-   */
-
-  _exit(status);
+  up_exit(status);
 }


[incubator-nuttx] 03/03: boards/xxx: Remove CONFIG_SCHED_ATEXIT/ONEXIT from all defconfigs

Posted by xi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git

commit 5800dd2af5cec8aca1b5cb94df8fc198fb4a522f
Author: Ville Juven <vi...@unikie.com>
AuthorDate: Fri May 6 14:15:51 2022 +0300

    boards/xxx: Remove CONFIG_SCHED_ATEXIT/ONEXIT from all defconfigs
---
 boards/arm/imx6/sabre-6quad/configs/libcxx/defconfig              | 2 +-
 boards/arm/lc823450/lc823450-xgevk/configs/audio/defconfig        | 4 +---
 boards/arm/lc823450/lc823450-xgevk/configs/bt/defconfig           | 4 +---
 boards/arm/lc823450/lc823450-xgevk/configs/elf/defconfig          | 4 +---
 boards/arm/lc823450/lc823450-xgevk/configs/ipl2/defconfig         | 4 +---
 boards/arm/lc823450/lc823450-xgevk/configs/knsh/defconfig         | 4 +---
 boards/arm/lc823450/lc823450-xgevk/configs/krndis/defconfig       | 4 +---
 boards/arm/lc823450/lc823450-xgevk/configs/nsh/defconfig          | 4 +---
 boards/arm/lc823450/lc823450-xgevk/configs/posix_spawn/defconfig  | 4 +---
 boards/arm/lc823450/lc823450-xgevk/configs/rndis/defconfig        | 4 +---
 boards/arm/lc823450/lc823450-xgevk/configs/usb/defconfig          | 4 +---
 boards/arm/lpc54xx/lpcxpresso-lpc54628/configs/nxwm/defconfig     | 2 +-
 boards/arm/lpc54xx/lpcxpresso-lpc54628/configs/pwfb/defconfig     | 2 +-
 boards/arm/lpc54xx/lpcxpresso-lpc54628/configs/pwlines/defconfig  | 2 +-
 boards/arm/lpc54xx/lpcxpresso-lpc54628/configs/twm4nx1/defconfig  | 2 +-
 boards/arm/lpc54xx/lpcxpresso-lpc54628/configs/twm4nx2/defconfig  | 2 +-
 boards/arm/sam34/sam3u-ek/configs/nxwm/defconfig                  | 2 +-
 boards/arm/sam34/sam4e-ek/configs/nxwm/defconfig                  | 2 +-
 boards/arm/sama5/sama5d3x-ek/configs/nxwm/defconfig               | 2 +-
 boards/arm/sama5/sama5d4-ek/configs/knsh/defconfig                | 3 +--
 boards/arm/sama5/sama5d4-ek/configs/nxwm/defconfig                | 2 +-
 boards/arm/samv7/samv71-xult/configs/nxwm/defconfig               | 2 +-
 boards/arm/samv7/samv71-xult/configs/vnxwm/defconfig              | 2 +-
 boards/arm/stm32/mikroe-stm32f4/configs/fulldemo/defconfig        | 3 +--
 boards/arm/stm32/mikroe-stm32f4/configs/kostest/defconfig         | 3 +--
 boards/arm/stm32/shenzhou/configs/nxwm/defconfig                  | 2 +-
 boards/arm/stm32/stm3220g-eval/configs/nxwm/defconfig             | 2 +-
 boards/arm/stm32/stm3240g-eval/configs/knxwm/defconfig            | 2 +-
 boards/arm/stm32/stm3240g-eval/configs/nxwm/defconfig             | 2 +-
 boards/arm/stm32/stm32f429i-disco/configs/nxhello/defconfig       | 2 +-
 boards/arm/stm32/stm32f429i-disco/configs/nxwm/defconfig          | 2 +-
 boards/arm/stm32/stm32f4discovery/configs/cxxtest/defconfig       | 3 +--
 boards/arm/stm32/stm32f4discovery/configs/testlibcxx/defconfig    | 3 +--
 boards/arm/stm32f7/stm32f746g-disco/configs/netnsh/defconfig      | 2 +-
 boards/risc-v/bl602/bl602evb/configs/wifi/defconfig               | 2 +-
 boards/risc-v/esp32c3/esp32c3-devkit/configs/autopm/defconfig     | 1 +
 boards/risc-v/esp32c3/esp32c3-devkit/configs/cxx/defconfig        | 2 +-
 boards/risc-v/esp32c3/esp32c3-devkit/configs/sta_softap/defconfig | 1 +
 boards/risc-v/esp32c3/esp32c3-devkit/configs/wapi/defconfig       | 1 +
 boards/risc-v/k210/maix-bit/configs/smp2/defconfig                | 4 +---
 boards/risc-v/mpfs/icicle/configs/knsh/defconfig                  | 3 +--
 boards/sim/sim/sim/configs/alsa/defconfig                         | 2 +-
 boards/sim/sim/sim/configs/asan/defconfig                         | 2 +-
 boards/sim/sim/sim/configs/bas/defconfig                          | 2 +-
 boards/sim/sim/sim/configs/bastest/defconfig                      | 2 +-
 boards/sim/sim/sim/configs/bluetooth/defconfig                    | 2 +-
 boards/sim/sim/sim/configs/bthcisock/defconfig                    | 2 +-
 boards/sim/sim/sim/configs/cxxtest/defconfig                      | 3 +--
 boards/sim/sim/sim/configs/duktape/defconfig                      | 2 +-
 boards/sim/sim/sim/configs/dynconns/defconfig                     | 2 +-
 boards/sim/sim/sim/configs/elf/defconfig                          | 2 +-
 boards/sim/sim/sim/configs/foc/defconfig                          | 2 +-
 boards/sim/sim/sim/configs/ipforward/defconfig                    | 2 +-
 boards/sim/sim/sim/configs/kasan/defconfig                        | 2 +-
 boards/sim/sim/sim/configs/libcxxtest/defconfig                   | 2 +-
 boards/sim/sim/sim/configs/linuxi2c/defconfig                     | 2 +-
 boards/sim/sim/sim/configs/linuxspi/defconfig                     | 2 +-
 boards/sim/sim/sim/configs/loadable/defconfig                     | 2 +-
 boards/sim/sim/sim/configs/lua/defconfig                          | 2 +-
 boards/sim/sim/sim/configs/minibasic/defconfig                    | 2 +-
 boards/sim/sim/sim/configs/module/defconfig                       | 2 +-
 boards/sim/sim/sim/configs/module32/defconfig                     | 2 +-
 boards/sim/sim/sim/configs/nimble/defconfig                       | 2 +-
 boards/sim/sim/sim/configs/note/defconfig                         | 2 +-
 boards/sim/sim/sim/configs/nsh/defconfig                          | 2 +-
 boards/sim/sim/sim/configs/nshcromfs/defconfig                    | 2 +-
 boards/sim/sim/sim/configs/nxlines/defconfig                      | 2 +-
 boards/sim/sim/sim/configs/nxwm/defconfig                         | 2 +-
 boards/sim/sim/sim/configs/posix_spawn/defconfig                  | 2 +-
 boards/sim/sim/sim/configs/rc/defconfig                           | 2 +-
 boards/sim/sim/sim/configs/romfs/defconfig                        | 2 +-
 boards/sim/sim/sim/configs/rust/defconfig                         | 2 +-
 boards/sim/sim/sim/configs/segger/defconfig                       | 2 +-
 boards/sim/sim/sim/configs/sensor/defconfig                       | 2 +-
 boards/sim/sim/sim/configs/smartfs/defconfig                      | 2 +-
 boards/sim/sim/sim/configs/sotest/defconfig                       | 2 +-
 boards/sim/sim/sim/configs/sotest32/defconfig                     | 2 +-
 boards/sim/sim/sim/configs/tcpblaster/defconfig                   | 2 +-
 boards/sim/sim/sim/configs/tcploop/defconfig                      | 2 +-
 boards/sim/sim/sim/configs/udgram/defconfig                       | 2 +-
 boards/sim/sim/sim/configs/unionfs/defconfig                      | 2 +-
 boards/sim/sim/sim/configs/userfs/defconfig                       | 2 +-
 boards/sim/sim/sim/configs/ustream/defconfig                      | 2 +-
 boards/sim/sim/sim/configs/vpnkit/defconfig                       | 2 +-
 boards/xtensa/esp32/esp32-devkitc/configs/cxx/defconfig           | 2 +-
 boards/xtensa/esp32s2/esp32s2-saola-1/configs/cxx/defconfig       | 2 +-
 boards/xtensa/esp32s3/esp32s3-devkit/configs/cxx/defconfig        | 2 +-
 87 files changed, 87 insertions(+), 113 deletions(-)

diff --git a/boards/arm/imx6/sabre-6quad/configs/libcxx/defconfig b/boards/arm/imx6/sabre-6quad/configs/libcxx/defconfig
index b080842b56..e3d0272595 100644
--- a/boards/arm/imx6/sabre-6quad/configs/libcxx/defconfig
+++ b/boards/arm/imx6/sabre-6quad/configs/libcxx/defconfig
@@ -38,6 +38,7 @@ CONFIG_INIT_ENTRYPOINT="nsh_main"
 CONFIG_INTELHEX_BINARY=y
 CONFIG_LIBCXX=y
 CONFIG_LIBCXXABI=y
+CONFIG_LIBC_MAX_EXITFUNS=1
 CONFIG_NSH_ARCHINIT=y
 CONFIG_NSH_BUILTIN_APPS=y
 CONFIG_NSH_FILEIOSIZE=512
@@ -51,7 +52,6 @@ CONFIG_RAM_VSTART=0x10000000
 CONFIG_RAW_BINARY=y
 CONFIG_READLINE_CMD_HISTORY=y
 CONFIG_RR_INTERVAL=200
-CONFIG_SCHED_ATEXIT=y
 CONFIG_SCHED_HPWORK=y
 CONFIG_SCHED_HPWORKPRIORITY=192
 CONFIG_SCHED_WAITPID=y
diff --git a/boards/arm/lc823450/lc823450-xgevk/configs/audio/defconfig b/boards/arm/lc823450/lc823450-xgevk/configs/audio/defconfig
index db298eb73a..0605354dbb 100644
--- a/boards/arm/lc823450/lc823450-xgevk/configs/audio/defconfig
+++ b/boards/arm/lc823450/lc823450-xgevk/configs/audio/defconfig
@@ -64,6 +64,7 @@ CONFIG_LC823450_UART0=y
 CONFIG_LCD=y
 CONFIG_LCD_ST7565=y
 CONFIG_LIBC_KBDCODEC=y
+CONFIG_LIBC_MAX_EXITFUNS=32
 CONFIG_LIBM=y
 CONFIG_MEMSET_OPTSPEED=y
 CONFIG_MQ_MAXMSGSIZE=64
@@ -103,11 +104,8 @@ CONFIG_RAW_BINARY=y
 CONFIG_READLINE_CMD_HISTORY=y
 CONFIG_RTC=y
 CONFIG_RTC_HIRES=y
-CONFIG_SCHED_ATEXIT=y
 CONFIG_SCHED_CHILD_STATUS=y
 CONFIG_SCHED_HAVE_PARENT=y
-CONFIG_SCHED_ONEXIT=y
-CONFIG_SCHED_ONEXIT_MAX=32
 CONFIG_SCHED_STARTHOOK=y
 CONFIG_SERIAL_TERMIOS=y
 CONFIG_SMP=y
diff --git a/boards/arm/lc823450/lc823450-xgevk/configs/bt/defconfig b/boards/arm/lc823450/lc823450-xgevk/configs/bt/defconfig
index ee42f53641..11f7162013 100644
--- a/boards/arm/lc823450/lc823450-xgevk/configs/bt/defconfig
+++ b/boards/arm/lc823450/lc823450-xgevk/configs/bt/defconfig
@@ -67,6 +67,7 @@ CONFIG_LC823450_XGEVK_BTPOWER=y
 CONFIG_LCD=y
 CONFIG_LCD_ST7565=y
 CONFIG_LIBC_KBDCODEC=y
+CONFIG_LIBC_MAX_EXITFUNS=32
 CONFIG_LIBM=y
 CONFIG_MEMSET_64BIT=y
 CONFIG_MEMSET_OPTSPEED=y
@@ -123,13 +124,10 @@ CONFIG_READLINE_CMD_HISTORY=y
 CONFIG_RR_INTERVAL=200
 CONFIG_RTC=y
 CONFIG_RTC_DATETIME=y
-CONFIG_SCHED_ATEXIT=y
 CONFIG_SCHED_CHILD_STATUS=y
 CONFIG_SCHED_HAVE_PARENT=y
 CONFIG_SCHED_LPWORK=y
 CONFIG_SCHED_LPWORKPRIORITY=60
-CONFIG_SCHED_ONEXIT=y
-CONFIG_SCHED_ONEXIT_MAX=32
 CONFIG_SCHED_STARTHOOK=y
 CONFIG_SENSORS=y
 CONFIG_SERIAL_TERMIOS=y
diff --git a/boards/arm/lc823450/lc823450-xgevk/configs/elf/defconfig b/boards/arm/lc823450/lc823450-xgevk/configs/elf/defconfig
index 8775ea3084..e5b2d3908c 100644
--- a/boards/arm/lc823450/lc823450-xgevk/configs/elf/defconfig
+++ b/boards/arm/lc823450/lc823450-xgevk/configs/elf/defconfig
@@ -35,6 +35,7 @@ CONFIG_INTELHEX_BINARY=y
 CONFIG_LC823450_UART0=y
 CONFIG_LIBC_ENVPATH=y
 CONFIG_LIBC_KBDCODEC=y
+CONFIG_LIBC_MAX_EXITFUNS=32
 CONFIG_LIBM=y
 CONFIG_MEMSET_OPTSPEED=y
 CONFIG_NAME_MAX=255
@@ -51,13 +52,10 @@ CONFIG_RAM_START=0x02001000
 CONFIG_RAW_BINARY=y
 CONFIG_RTC=y
 CONFIG_RTC_DATETIME=y
-CONFIG_SCHED_ATEXIT=y
 CONFIG_SCHED_CHILD_STATUS=y
 CONFIG_SCHED_HAVE_PARENT=y
 CONFIG_SCHED_INSTRUMENTATION=y
 CONFIG_SCHED_INSTRUMENTATION_SWITCH=y
-CONFIG_SCHED_ONEXIT=y
-CONFIG_SCHED_ONEXIT_MAX=32
 CONFIG_SCHED_STARTHOOK=y
 CONFIG_SCHED_WAITPID=y
 CONFIG_SERIAL_TERMIOS=y
diff --git a/boards/arm/lc823450/lc823450-xgevk/configs/ipl2/defconfig b/boards/arm/lc823450/lc823450-xgevk/configs/ipl2/defconfig
index 3a2808d7ff..d2686d6744 100644
--- a/boards/arm/lc823450/lc823450-xgevk/configs/ipl2/defconfig
+++ b/boards/arm/lc823450/lc823450-xgevk/configs/ipl2/defconfig
@@ -34,6 +34,7 @@ CONFIG_LC823450_MTD=y
 CONFIG_LC823450_SDIF_SDC=y
 CONFIG_LC823450_UART0=y
 CONFIG_LC823450_UART1=y
+CONFIG_LIBC_MAX_EXITFUNS=32
 CONFIG_LIBM=y
 CONFIG_MEMSET_OPTSPEED=y
 CONFIG_MTD=y
@@ -50,13 +51,10 @@ CONFIG_RAM_START=0x02001000
 CONFIG_RAW_BINARY=y
 CONFIG_RTC=y
 CONFIG_RTC_DATETIME=y
-CONFIG_SCHED_ATEXIT=y
 CONFIG_SCHED_CHILD_STATUS=y
 CONFIG_SCHED_HAVE_PARENT=y
 CONFIG_SCHED_INSTRUMENTATION=y
 CONFIG_SCHED_INSTRUMENTATION_SWITCH=y
-CONFIG_SCHED_ONEXIT=y
-CONFIG_SCHED_ONEXIT_MAX=32
 CONFIG_SCHED_STARTHOOK=y
 CONFIG_SCHED_WAITPID=y
 CONFIG_SENSORS=y
diff --git a/boards/arm/lc823450/lc823450-xgevk/configs/knsh/defconfig b/boards/arm/lc823450/lc823450-xgevk/configs/knsh/defconfig
index f9797ff805..2ab00eca4c 100644
--- a/boards/arm/lc823450/lc823450-xgevk/configs/knsh/defconfig
+++ b/boards/arm/lc823450/lc823450-xgevk/configs/knsh/defconfig
@@ -47,6 +47,7 @@ CONFIG_LC823450_WDT=y
 CONFIG_LCD=y
 CONFIG_LCD_ST7565=y
 CONFIG_LIBC_KBDCODEC=y
+CONFIG_LIBC_MAX_EXITFUNS=32
 CONFIG_LIBM=y
 CONFIG_MEMSET_OPTSPEED=y
 CONFIG_MQ_MAXMSGSIZE=64
@@ -93,13 +94,10 @@ CONFIG_RAW_BINARY=y
 CONFIG_READLINE_CMD_HISTORY=y
 CONFIG_RTC=y
 CONFIG_RTC_DATETIME=y
-CONFIG_SCHED_ATEXIT=y
 CONFIG_SCHED_CHILD_STATUS=y
 CONFIG_SCHED_HAVE_PARENT=y
 CONFIG_SCHED_INSTRUMENTATION=y
 CONFIG_SCHED_INSTRUMENTATION_SWITCH=y
-CONFIG_SCHED_ONEXIT=y
-CONFIG_SCHED_ONEXIT_MAX=32
 CONFIG_SCHED_STARTHOOK=y
 CONFIG_SCHED_WAITPID=y
 CONFIG_SERIAL_TERMIOS=y
diff --git a/boards/arm/lc823450/lc823450-xgevk/configs/krndis/defconfig b/boards/arm/lc823450/lc823450-xgevk/configs/krndis/defconfig
index b20fad067a..60486cfedd 100644
--- a/boards/arm/lc823450/lc823450-xgevk/configs/krndis/defconfig
+++ b/boards/arm/lc823450/lc823450-xgevk/configs/krndis/defconfig
@@ -77,6 +77,7 @@ CONFIG_LCD_ST7565=y
 CONFIG_LIBC_ENVPATH=y
 CONFIG_LIBC_EXECFUNCS=y
 CONFIG_LIBC_KBDCODEC=y
+CONFIG_LIBC_MAX_EXITFUNS=32
 CONFIG_LIBM=y
 CONFIG_MEMSET_OPTSPEED=y
 CONFIG_MQ_MAXMSGSIZE=64
@@ -144,7 +145,6 @@ CONFIG_READLINE_CMD_HISTORY=y
 CONFIG_RNDIS=y
 CONFIG_RTC=y
 CONFIG_RTC_HIRES=y
-CONFIG_SCHED_ATEXIT=y
 CONFIG_SCHED_CHILD_STATUS=y
 CONFIG_SCHED_HAVE_PARENT=y
 CONFIG_SCHED_HPWORK=y
@@ -154,8 +154,6 @@ CONFIG_SCHED_INSTRUMENTATION_PREEMPTION=y
 CONFIG_SCHED_INSTRUMENTATION_SWITCH=y
 CONFIG_SCHED_LPWORK=y
 CONFIG_SCHED_LPWORKPRIORITY=60
-CONFIG_SCHED_ONEXIT=y
-CONFIG_SCHED_ONEXIT_MAX=32
 CONFIG_SCHED_STARTHOOK=y
 CONFIG_SCHED_WAITPID=y
 CONFIG_SENSORS=y
diff --git a/boards/arm/lc823450/lc823450-xgevk/configs/nsh/defconfig b/boards/arm/lc823450/lc823450-xgevk/configs/nsh/defconfig
index cc7568c212..86c66184ac 100644
--- a/boards/arm/lc823450/lc823450-xgevk/configs/nsh/defconfig
+++ b/boards/arm/lc823450/lc823450-xgevk/configs/nsh/defconfig
@@ -52,6 +52,7 @@ CONFIG_LC823450_WDT=y
 CONFIG_LCD=y
 CONFIG_LCD_ST7565=y
 CONFIG_LIBC_KBDCODEC=y
+CONFIG_LIBC_MAX_EXITFUNS=32
 CONFIG_LIBM=y
 CONFIG_MEMSET_OPTSPEED=y
 CONFIG_MQ_MAXMSGSIZE=64
@@ -97,11 +98,8 @@ CONFIG_RAW_BINARY=y
 CONFIG_READLINE_CMD_HISTORY=y
 CONFIG_RTC=y
 CONFIG_RTC_DATETIME=y
-CONFIG_SCHED_ATEXIT=y
 CONFIG_SCHED_CHILD_STATUS=y
 CONFIG_SCHED_HAVE_PARENT=y
-CONFIG_SCHED_ONEXIT=y
-CONFIG_SCHED_ONEXIT_MAX=32
 CONFIG_SCHED_STARTHOOK=y
 CONFIG_SCHED_WAITPID=y
 CONFIG_SERIAL_TERMIOS=y
diff --git a/boards/arm/lc823450/lc823450-xgevk/configs/posix_spawn/defconfig b/boards/arm/lc823450/lc823450-xgevk/configs/posix_spawn/defconfig
index b1fc518073..1f3d43df30 100644
--- a/boards/arm/lc823450/lc823450-xgevk/configs/posix_spawn/defconfig
+++ b/boards/arm/lc823450/lc823450-xgevk/configs/posix_spawn/defconfig
@@ -34,6 +34,7 @@ CONFIG_LC823450_UART0=y
 CONFIG_LIBC_ENVPATH=y
 CONFIG_LIBC_EXECFUNCS=y
 CONFIG_LIBC_KBDCODEC=y
+CONFIG_LIBC_MAX_EXITFUNS=32
 CONFIG_LIBM=y
 CONFIG_MEMSET_OPTSPEED=y
 CONFIG_NAME_MAX=255
@@ -50,13 +51,10 @@ CONFIG_RAM_START=0x02001000
 CONFIG_RAW_BINARY=y
 CONFIG_RTC=y
 CONFIG_RTC_DATETIME=y
-CONFIG_SCHED_ATEXIT=y
 CONFIG_SCHED_CHILD_STATUS=y
 CONFIG_SCHED_HAVE_PARENT=y
 CONFIG_SCHED_INSTRUMENTATION=y
 CONFIG_SCHED_INSTRUMENTATION_SWITCH=y
-CONFIG_SCHED_ONEXIT=y
-CONFIG_SCHED_ONEXIT_MAX=32
 CONFIG_SCHED_STARTHOOK=y
 CONFIG_SCHED_WAITPID=y
 CONFIG_SERIAL_TERMIOS=y
diff --git a/boards/arm/lc823450/lc823450-xgevk/configs/rndis/defconfig b/boards/arm/lc823450/lc823450-xgevk/configs/rndis/defconfig
index ce6f425f82..e79f3f011b 100644
--- a/boards/arm/lc823450/lc823450-xgevk/configs/rndis/defconfig
+++ b/boards/arm/lc823450/lc823450-xgevk/configs/rndis/defconfig
@@ -74,6 +74,7 @@ CONFIG_LCD_ST7565=y
 CONFIG_LIBC_ENVPATH=y
 CONFIG_LIBC_EXECFUNCS=y
 CONFIG_LIBC_KBDCODEC=y
+CONFIG_LIBC_MAX_EXITFUNS=32
 CONFIG_LIBM=y
 CONFIG_MEMSET_OPTSPEED=y
 CONFIG_MQ_MAXMSGSIZE=64
@@ -146,15 +147,12 @@ CONFIG_READLINE_CMD_HISTORY=y
 CONFIG_RNDIS=y
 CONFIG_RTC=y
 CONFIG_RTC_HIRES=y
-CONFIG_SCHED_ATEXIT=y
 CONFIG_SCHED_CHILD_STATUS=y
 CONFIG_SCHED_HAVE_PARENT=y
 CONFIG_SCHED_HPWORK=y
 CONFIG_SCHED_HPWORKPRIORITY=192
 CONFIG_SCHED_LPWORK=y
 CONFIG_SCHED_LPWORKPRIORITY=60
-CONFIG_SCHED_ONEXIT=y
-CONFIG_SCHED_ONEXIT_MAX=32
 CONFIG_SCHED_STARTHOOK=y
 CONFIG_SENSORS=y
 CONFIG_SERIAL_TERMIOS=y
diff --git a/boards/arm/lc823450/lc823450-xgevk/configs/usb/defconfig b/boards/arm/lc823450/lc823450-xgevk/configs/usb/defconfig
index 71532c9089..0ade37cddd 100644
--- a/boards/arm/lc823450/lc823450-xgevk/configs/usb/defconfig
+++ b/boards/arm/lc823450/lc823450-xgevk/configs/usb/defconfig
@@ -60,6 +60,7 @@ CONFIG_LC823450_WDT=y
 CONFIG_LCD=y
 CONFIG_LCD_ST7565=y
 CONFIG_LIBC_KBDCODEC=y
+CONFIG_LIBC_MAX_EXITFUNS=32
 CONFIG_LIBM=y
 CONFIG_MEMSET_OPTSPEED=y
 CONFIG_MQ_MAXMSGSIZE=64
@@ -99,11 +100,8 @@ CONFIG_RAW_BINARY=y
 CONFIG_READLINE_CMD_HISTORY=y
 CONFIG_RTC=y
 CONFIG_RTC_DATETIME=y
-CONFIG_SCHED_ATEXIT=y
 CONFIG_SCHED_CHILD_STATUS=y
 CONFIG_SCHED_HAVE_PARENT=y
-CONFIG_SCHED_ONEXIT=y
-CONFIG_SCHED_ONEXIT_MAX=32
 CONFIG_SCHED_STARTHOOK=y
 CONFIG_SENSORS=y
 CONFIG_SERIAL_TERMIOS=y
diff --git a/boards/arm/lpc54xx/lpcxpresso-lpc54628/configs/nxwm/defconfig b/boards/arm/lpc54xx/lpcxpresso-lpc54628/configs/nxwm/defconfig
index c925e33917..dae0f67c79 100644
--- a/boards/arm/lpc54xx/lpcxpresso-lpc54628/configs/nxwm/defconfig
+++ b/boards/arm/lpc54xx/lpcxpresso-lpc54628/configs/nxwm/defconfig
@@ -32,6 +32,7 @@ CONFIG_HAVE_CXXINITIALIZE=y
 CONFIG_INIT_ENTRYPOINT="nxwm_main"
 CONFIG_INPUT=y
 CONFIG_INPUT_FT5X06=y
+CONFIG_LIBC_MAX_EXITFUNS=1
 CONFIG_LPC54_EMC=y
 CONFIG_LPC54_EMC_DYNAMIC_CS0=y
 CONFIG_LPC54_EMC_DYNAMIC_CS0_OFFSET=0x00080000
@@ -91,7 +92,6 @@ CONFIG_RAM_START=0x20000000
 CONFIG_RAW_BINARY=y
 CONFIG_RR_INTERVAL=200
 CONFIG_SCHED_HPWORK=y
-CONFIG_SCHED_ONEXIT=y
 CONFIG_SCHED_WAITPID=y
 CONFIG_START_DAY=18
 CONFIG_START_MONTH=12
diff --git a/boards/arm/lpc54xx/lpcxpresso-lpc54628/configs/pwfb/defconfig b/boards/arm/lpc54xx/lpcxpresso-lpc54628/configs/pwfb/defconfig
index b265207011..d6f69d51bf 100644
--- a/boards/arm/lpc54xx/lpcxpresso-lpc54628/configs/pwfb/defconfig
+++ b/boards/arm/lpc54xx/lpcxpresso-lpc54628/configs/pwfb/defconfig
@@ -34,6 +34,7 @@ CONFIG_EXAMPLES_PWFB_TBCOLOR=0xad55
 CONFIG_FS_PROCFS=y
 CONFIG_INIT_ENTRYPOINT="pwfb_main"
 CONFIG_INTELHEX_BINARY=y
+CONFIG_LIBC_MAX_EXITFUNS=1
 CONFIG_LPC54_EMC=y
 CONFIG_LPC54_EMC_DYNAMIC_CS0=y
 CONFIG_LPC54_EMC_DYNAMIC_CS0_OFFSET=0x00080000
@@ -62,7 +63,6 @@ CONFIG_RAM_START=0x20000000
 CONFIG_RR_INTERVAL=200
 CONFIG_SCHED_HPWORK=y
 CONFIG_SCHED_HPWORKPRIORITY=192
-CONFIG_SCHED_ONEXIT=y
 CONFIG_SCHED_WAITPID=y
 CONFIG_START_DAY=19
 CONFIG_START_MONTH=3
diff --git a/boards/arm/lpc54xx/lpcxpresso-lpc54628/configs/pwlines/defconfig b/boards/arm/lpc54xx/lpcxpresso-lpc54628/configs/pwlines/defconfig
index 0c2fc11980..c98010c5e3 100644
--- a/boards/arm/lpc54xx/lpcxpresso-lpc54628/configs/pwlines/defconfig
+++ b/boards/arm/lpc54xx/lpcxpresso-lpc54628/configs/pwlines/defconfig
@@ -25,6 +25,7 @@ CONFIG_EXAMPLES_PWLINES_BPP=16
 CONFIG_FS_PROCFS=y
 CONFIG_INIT_ENTRYPOINT="pwlines_main"
 CONFIG_INTELHEX_BINARY=y
+CONFIG_LIBC_MAX_EXITFUNS=1
 CONFIG_LPC54_EMC=y
 CONFIG_LPC54_EMC_DYNAMIC_CS0=y
 CONFIG_LPC54_EMC_DYNAMIC_CS0_OFFSET=0x00080000
@@ -55,7 +56,6 @@ CONFIG_RAM_START=0x20000000
 CONFIG_RR_INTERVAL=200
 CONFIG_SCHED_HPWORK=y
 CONFIG_SCHED_HPWORKPRIORITY=192
-CONFIG_SCHED_ONEXIT=y
 CONFIG_SCHED_WAITPID=y
 CONFIG_START_DAY=19
 CONFIG_START_MONTH=3
diff --git a/boards/arm/lpc54xx/lpcxpresso-lpc54628/configs/twm4nx1/defconfig b/boards/arm/lpc54xx/lpcxpresso-lpc54628/configs/twm4nx1/defconfig
index 5bd31f0321..d42e71c061 100644
--- a/boards/arm/lpc54xx/lpcxpresso-lpc54628/configs/twm4nx1/defconfig
+++ b/boards/arm/lpc54xx/lpcxpresso-lpc54628/configs/twm4nx1/defconfig
@@ -33,6 +33,7 @@ CONFIG_INIT_ENTRYPOINT="twm4nx_main"
 CONFIG_INPUT=y
 CONFIG_INPUT_FT5X06=y
 CONFIG_LIBC_HOSTNAME="LPCXpresso-LPC54628"
+CONFIG_LIBC_MAX_EXITFUNS=1
 CONFIG_LPC54_EMC=y
 CONFIG_LPC54_EMC_DYNAMIC_CS0=y
 CONFIG_LPC54_EMC_DYNAMIC_CS0_OFFSET=0x00080000
@@ -87,7 +88,6 @@ CONFIG_RAM_START=0x20000000
 CONFIG_RAW_BINARY=y
 CONFIG_RR_INTERVAL=200
 CONFIG_SCHED_HPWORK=y
-CONFIG_SCHED_ONEXIT=y
 CONFIG_SCHED_WAITPID=y
 CONFIG_START_DAY=4
 CONFIG_START_MONTH=5
diff --git a/boards/arm/lpc54xx/lpcxpresso-lpc54628/configs/twm4nx2/defconfig b/boards/arm/lpc54xx/lpcxpresso-lpc54628/configs/twm4nx2/defconfig
index 6b17acee8f..e9f7bc21d3 100644
--- a/boards/arm/lpc54xx/lpcxpresso-lpc54628/configs/twm4nx2/defconfig
+++ b/boards/arm/lpc54xx/lpcxpresso-lpc54628/configs/twm4nx2/defconfig
@@ -33,6 +33,7 @@ CONFIG_INIT_ENTRYPOINT="twm4nx_main"
 CONFIG_INPUT=y
 CONFIG_INPUT_FT5X06=y
 CONFIG_LIBC_HOSTNAME="LPCXpresso-LPC54628"
+CONFIG_LIBC_MAX_EXITFUNS=1
 CONFIG_LPC54_EMC=y
 CONFIG_LPC54_EMC_DYNAMIC_CS0=y
 CONFIG_LPC54_EMC_DYNAMIC_CS0_OFFSET=0x00080000
@@ -88,7 +89,6 @@ CONFIG_RAM_START=0x20000000
 CONFIG_RAW_BINARY=y
 CONFIG_RR_INTERVAL=200
 CONFIG_SCHED_HPWORK=y
-CONFIG_SCHED_ONEXIT=y
 CONFIG_SCHED_WAITPID=y
 CONFIG_START_DAY=4
 CONFIG_START_MONTH=5
diff --git a/boards/arm/sam34/sam3u-ek/configs/nxwm/defconfig b/boards/arm/sam34/sam3u-ek/configs/nxwm/defconfig
index f2cca7d467..7d9f5bbd6a 100644
--- a/boards/arm/sam34/sam3u-ek/configs/nxwm/defconfig
+++ b/boards/arm/sam34/sam3u-ek/configs/nxwm/defconfig
@@ -36,6 +36,7 @@ CONFIG_INPUT_ADS7843E=y
 CONFIG_LCD=y
 CONFIG_LCD_MAXCONTRAST=1
 CONFIG_LCD_MAXPOWER=31
+CONFIG_LIBC_MAX_EXITFUNS=1
 CONFIG_MM_REGIONS=3
 CONFIG_MQ_MAXMSGSIZE=64
 CONFIG_NSH_ARCHINIT=y
@@ -85,7 +86,6 @@ CONFIG_SAM34_GPIO_IRQ=y
 CONFIG_SAM34_SPI0=y
 CONFIG_SCHED_HPWORK=y
 CONFIG_SCHED_HPWORKPRIORITY=192
-CONFIG_SCHED_ONEXIT=y
 CONFIG_SCHED_WAITPID=y
 CONFIG_START_DAY=28
 CONFIG_START_MONTH=6
diff --git a/boards/arm/sam34/sam4e-ek/configs/nxwm/defconfig b/boards/arm/sam34/sam4e-ek/configs/nxwm/defconfig
index 016d3babfe..d1fbf78e32 100644
--- a/boards/arm/sam34/sam4e-ek/configs/nxwm/defconfig
+++ b/boards/arm/sam34/sam4e-ek/configs/nxwm/defconfig
@@ -41,6 +41,7 @@ CONFIG_LCD=y
 CONFIG_LCD_MAXCONTRAST=1
 CONFIG_LCD_MAXPOWER=64
 CONFIG_LIBC_FLOATINGPOINT=y
+CONFIG_LIBC_MAX_EXITFUNS=1
 CONFIG_LIBM=y
 CONFIG_MM_REGIONS=2
 CONFIG_MQ_MAXMSGSIZE=64
@@ -131,7 +132,6 @@ CONFIG_SAM4EEK_LCD_BGCOLOR=0x95fa
 CONFIG_SCHED_HAVE_PARENT=y
 CONFIG_SCHED_HPWORK=y
 CONFIG_SCHED_HPWORKPRIORITY=192
-CONFIG_SCHED_ONEXIT=y
 CONFIG_SCHED_WAITPID=y
 CONFIG_START_DAY=10
 CONFIG_START_MONTH=3
diff --git a/boards/arm/sama5/sama5d3x-ek/configs/nxwm/defconfig b/boards/arm/sama5/sama5d3x-ek/configs/nxwm/defconfig
index 2c979161e3..ce739ccfe6 100644
--- a/boards/arm/sama5/sama5d3x-ek/configs/nxwm/defconfig
+++ b/boards/arm/sama5/sama5d3x-ek/configs/nxwm/defconfig
@@ -31,6 +31,7 @@ CONFIG_INIT_ENTRYPOINT="nxwm_main"
 CONFIG_INIT_STACKSIZE=1024
 CONFIG_INTELHEX_BINARY=y
 CONFIG_LIBC_FLOATINGPOINT=y
+CONFIG_LIBC_MAX_EXITFUNS=1
 CONFIG_LIBM=y
 CONFIG_MM_REGIONS=2
 CONFIG_MQ_MAXMSGSIZE=64
@@ -112,7 +113,6 @@ CONFIG_SAMA5_TSD_SWAPXY=y
 CONFIG_SAMA5_USART1=y
 CONFIG_SCHED_HPWORK=y
 CONFIG_SCHED_HPWORKPRIORITY=192
-CONFIG_SCHED_ONEXIT=y
 CONFIG_SCHED_WAITPID=y
 CONFIG_START_DAY=13
 CONFIG_START_MONTH=10
diff --git a/boards/arm/sama5/sama5d4-ek/configs/knsh/defconfig b/boards/arm/sama5/sama5d4-ek/configs/knsh/defconfig
index 1bad14b9ed..fdc8ff0aad 100644
--- a/boards/arm/sama5/sama5d4-ek/configs/knsh/defconfig
+++ b/boards/arm/sama5/sama5d4-ek/configs/knsh/defconfig
@@ -48,6 +48,7 @@ CONFIG_HAVE_CXXINITIALIZE=y
 CONFIG_HOST_WINDOWS=y
 CONFIG_INTELHEX_BINARY=y
 CONFIG_LIBC_EXECFUNCS=y
+CONFIG_LIBC_MAX_EXITFUNS=2
 CONFIG_MMCSD=y
 CONFIG_MMCSD_MULTIBLOCK_LIMIT=1
 CONFIG_MMCSD_SDIO=y
@@ -78,8 +79,6 @@ CONFIG_SAMA5_XDMAC0=y
 CONFIG_SCHED_HAVE_PARENT=y
 CONFIG_SCHED_HPWORK=y
 CONFIG_SCHED_HPWORKPRIORITY=192
-CONFIG_SCHED_ONEXIT=y
-CONFIG_SCHED_ONEXIT_MAX=2
 CONFIG_SCHED_WAITPID=y
 CONFIG_SDIO_BLOCKSETUP=y
 CONFIG_SYSTEM_NSH=y
diff --git a/boards/arm/sama5/sama5d4-ek/configs/nxwm/defconfig b/boards/arm/sama5/sama5d4-ek/configs/nxwm/defconfig
index 70db44feaa..e7c1540f19 100644
--- a/boards/arm/sama5/sama5d4-ek/configs/nxwm/defconfig
+++ b/boards/arm/sama5/sama5d4-ek/configs/nxwm/defconfig
@@ -56,6 +56,7 @@ CONFIG_INPUT=y
 CONFIG_INPUT_MXT=y
 CONFIG_INTELHEX_BINARY=y
 CONFIG_LIBC_FLOATINGPOINT=y
+CONFIG_LIBC_MAX_EXITFUNS=1
 CONFIG_LIBM=y
 CONFIG_MMCSD=y
 CONFIG_MMCSD_MULTIBLOCK_LIMIT=1
@@ -179,7 +180,6 @@ CONFIG_SAMA5_XDMAC0=y
 CONFIG_SCHED_HAVE_PARENT=y
 CONFIG_SCHED_HPWORK=y
 CONFIG_SCHED_HPWORKPRIORITY=192
-CONFIG_SCHED_ONEXIT=y
 CONFIG_SCHED_WAITPID=y
 CONFIG_SDIO_BLOCKSETUP=y
 CONFIG_SYMTAB_ORDEREDBYNAME=y
diff --git a/boards/arm/samv7/samv71-xult/configs/nxwm/defconfig b/boards/arm/samv7/samv71-xult/configs/nxwm/defconfig
index 99be08f1f9..b2e68cf910 100644
--- a/boards/arm/samv7/samv71-xult/configs/nxwm/defconfig
+++ b/boards/arm/samv7/samv71-xult/configs/nxwm/defconfig
@@ -52,6 +52,7 @@ CONFIG_INPUT_MXT=y
 CONFIG_LCD=y
 CONFIG_LCD_NOGETRUN=y
 CONFIG_LIBC_FLOATINGPOINT=y
+CONFIG_LIBC_MAX_EXITFUNS=1
 CONFIG_LIBM=y
 CONFIG_MMCSD_MULTIBLOCK_LIMIT=1
 CONFIG_MMCSD_SDIO=y
@@ -117,7 +118,6 @@ CONFIG_SAMV7_XDMAC=y
 CONFIG_SCHED_HAVE_PARENT=y
 CONFIG_SCHED_HPWORK=y
 CONFIG_SCHED_HPWORKPRIORITY=192
-CONFIG_SCHED_ONEXIT=y
 CONFIG_SCHED_WAITPID=y
 CONFIG_SDIO_BLOCKSETUP=y
 CONFIG_START_DAY=10
diff --git a/boards/arm/samv7/samv71-xult/configs/vnxwm/defconfig b/boards/arm/samv7/samv71-xult/configs/vnxwm/defconfig
index dd6d454478..2a9148b1dd 100644
--- a/boards/arm/samv7/samv71-xult/configs/vnxwm/defconfig
+++ b/boards/arm/samv7/samv71-xult/configs/vnxwm/defconfig
@@ -53,6 +53,7 @@ CONFIG_IOB_NBUFFERS=72
 CONFIG_IOB_THROTTLE=32
 CONFIG_LIBC_FLOATINGPOINT=y
 CONFIG_LIBC_HOSTNAME="SAMV71-XULT"
+CONFIG_LIBC_MAX_EXITFUNS=1
 CONFIG_LIBM=y
 CONFIG_MMCSD_MULTIBLOCK_LIMIT=1
 CONFIG_MMCSD_SDIO=y
@@ -138,7 +139,6 @@ CONFIG_SAMV7_XDMAC=y
 CONFIG_SCHED_HAVE_PARENT=y
 CONFIG_SCHED_HPWORK=y
 CONFIG_SCHED_HPWORKPRIORITY=192
-CONFIG_SCHED_ONEXIT=y
 CONFIG_SCHED_WAITPID=y
 CONFIG_SDIO_BLOCKSETUP=y
 CONFIG_START_DAY=10
diff --git a/boards/arm/stm32/mikroe-stm32f4/configs/fulldemo/defconfig b/boards/arm/stm32/mikroe-stm32f4/configs/fulldemo/defconfig
index f124e89dba..955aebf4dd 100644
--- a/boards/arm/stm32/mikroe-stm32f4/configs/fulldemo/defconfig
+++ b/boards/arm/stm32/mikroe-stm32f4/configs/fulldemo/defconfig
@@ -51,6 +51,7 @@ CONFIG_INPUT=y
 CONFIG_INTELHEX_BINARY=y
 CONFIG_LCD=y
 CONFIG_LCD_MIO283QT2=y
+CONFIG_LIBC_MAX_EXITFUNS=4
 CONFIG_LIBC_PERROR_STDOUT=y
 CONFIG_LIBC_STRERROR=y
 CONFIG_M25P_MANUFACTURER=0x1C
@@ -117,8 +118,6 @@ CONFIG_RTC_ALARM=y
 CONFIG_RTC_DATETIME=y
 CONFIG_SCHED_HPWORK=y
 CONFIG_SCHED_HPWORKPRIORITY=192
-CONFIG_SCHED_ONEXIT=y
-CONFIG_SCHED_ONEXIT_MAX=4
 CONFIG_SCHED_WAITPID=y
 CONFIG_STM32_ADC2=y
 CONFIG_STM32_DISABLE_IDLE_SLEEP_DURING_DEBUG=y
diff --git a/boards/arm/stm32/mikroe-stm32f4/configs/kostest/defconfig b/boards/arm/stm32/mikroe-stm32f4/configs/kostest/defconfig
index b04cf883ca..c06f6a324c 100644
--- a/boards/arm/stm32/mikroe-stm32f4/configs/kostest/defconfig
+++ b/boards/arm/stm32/mikroe-stm32f4/configs/kostest/defconfig
@@ -35,6 +35,7 @@ CONFIG_HAVE_CXXINITIALIZE=y
 CONFIG_IDLETHREAD_STACKSIZE=2048
 CONFIG_INIT_ENTRYPOINT="ostest_main"
 CONFIG_INTELHEX_BINARY=y
+CONFIG_LIBC_MAX_EXITFUNS=4
 CONFIG_LIBC_PERROR_STDOUT=y
 CONFIG_LIBC_STRERROR=y
 CONFIG_M25P_MANUFACTURER=0x1C
@@ -64,8 +65,6 @@ CONFIG_RTC_ALARM=y
 CONFIG_RTC_DATETIME=y
 CONFIG_SCHED_HPWORK=y
 CONFIG_SCHED_HPWORKPRIORITY=192
-CONFIG_SCHED_ONEXIT=y
-CONFIG_SCHED_ONEXIT_MAX=4
 CONFIG_SCHED_WAITPID=y
 CONFIG_STM32_ADC2=y
 CONFIG_STM32_DISABLE_IDLE_SLEEP_DURING_DEBUG=y
diff --git a/boards/arm/stm32/shenzhou/configs/nxwm/defconfig b/boards/arm/stm32/shenzhou/configs/nxwm/defconfig
index e51eaece7e..19a134aa92 100644
--- a/boards/arm/stm32/shenzhou/configs/nxwm/defconfig
+++ b/boards/arm/stm32/shenzhou/configs/nxwm/defconfig
@@ -37,6 +37,7 @@ CONFIG_LCD=y
 CONFIG_LCD_MAXCONTRAST=1
 CONFIG_LCD_NOGETRUN=y
 CONFIG_LCD_SSD1289=y
+CONFIG_LIBC_MAX_EXITFUNS=1
 CONFIG_MQ_MAXMSGSIZE=64
 CONFIG_NET=y
 CONFIG_NETDB_DNSCLIENT=y
@@ -102,7 +103,6 @@ CONFIG_RR_INTERVAL=200
 CONFIG_SCHED_HPWORK=y
 CONFIG_SCHED_HPWORKPRIORITY=192
 CONFIG_SCHED_HPWORKSTACKSIZE=1024
-CONFIG_SCHED_ONEXIT=y
 CONFIG_START_DAY=26
 CONFIG_START_MONTH=9
 CONFIG_START_YEAR=2012
diff --git a/boards/arm/stm32/stm3220g-eval/configs/nxwm/defconfig b/boards/arm/stm32/stm3220g-eval/configs/nxwm/defconfig
index 2a4ce2a020..fb1ce1a428 100644
--- a/boards/arm/stm32/stm3220g-eval/configs/nxwm/defconfig
+++ b/boards/arm/stm32/stm3220g-eval/configs/nxwm/defconfig
@@ -37,6 +37,7 @@ CONFIG_INTELHEX_BINARY=y
 CONFIG_LCD=y
 CONFIG_LCD_MAXCONTRAST=1
 CONFIG_LCD_NOGETRUN=y
+CONFIG_LIBC_MAX_EXITFUNS=1
 CONFIG_MMCSD=y
 CONFIG_MMCSD_MULTIBLOCK_LIMIT=1
 CONFIG_MQ_MAXMSGSIZE=64
@@ -98,7 +99,6 @@ CONFIG_RR_INTERVAL=200
 CONFIG_RTC_DATETIME=y
 CONFIG_SCHED_HPWORK=y
 CONFIG_SCHED_HPWORKPRIORITY=192
-CONFIG_SCHED_ONEXIT=y
 CONFIG_SCHED_WAITPID=y
 CONFIG_STM32_DFU=y
 CONFIG_STM32_ETHMAC=y
diff --git a/boards/arm/stm32/stm3240g-eval/configs/knxwm/defconfig b/boards/arm/stm32/stm3240g-eval/configs/knxwm/defconfig
index 62017c19fd..4c185f7e6a 100644
--- a/boards/arm/stm32/stm3240g-eval/configs/knxwm/defconfig
+++ b/boards/arm/stm32/stm3240g-eval/configs/knxwm/defconfig
@@ -38,6 +38,7 @@ CONFIG_INTELHEX_BINARY=y
 CONFIG_LCD=y
 CONFIG_LCD_MAXCONTRAST=1
 CONFIG_LCD_NOGETRUN=y
+CONFIG_LIBC_MAX_EXITFUNS=1
 CONFIG_LIBC_USRWORK=y
 CONFIG_MM_REGIONS=2
 CONFIG_MQ_MAXMSGSIZE=64
@@ -76,7 +77,6 @@ CONFIG_RR_INTERVAL=200
 CONFIG_RTC_DATETIME=y
 CONFIG_SCHED_HPWORK=y
 CONFIG_SCHED_HPWORKPRIORITY=192
-CONFIG_SCHED_ONEXIT=y
 CONFIG_SCHED_WAITPID=y
 CONFIG_STM32_DFU=y
 CONFIG_STM32_FSMC=y
diff --git a/boards/arm/stm32/stm3240g-eval/configs/nxwm/defconfig b/boards/arm/stm32/stm3240g-eval/configs/nxwm/defconfig
index 06bb01060c..271233fb6f 100644
--- a/boards/arm/stm32/stm3240g-eval/configs/nxwm/defconfig
+++ b/boards/arm/stm32/stm3240g-eval/configs/nxwm/defconfig
@@ -36,6 +36,7 @@ CONFIG_INTELHEX_BINARY=y
 CONFIG_LCD=y
 CONFIG_LCD_MAXCONTRAST=1
 CONFIG_LCD_NOGETRUN=y
+CONFIG_LIBC_MAX_EXITFUNS=1
 CONFIG_MM_REGIONS=2
 CONFIG_MQ_MAXMSGSIZE=64
 CONFIG_NET=y
@@ -95,7 +96,6 @@ CONFIG_RR_INTERVAL=200
 CONFIG_RTC_DATETIME=y
 CONFIG_SCHED_HPWORK=y
 CONFIG_SCHED_HPWORKPRIORITY=192
-CONFIG_SCHED_ONEXIT=y
 CONFIG_SCHED_WAITPID=y
 CONFIG_STM32_DFU=y
 CONFIG_STM32_ETHMAC=y
diff --git a/boards/arm/stm32/stm32f429i-disco/configs/nxhello/defconfig b/boards/arm/stm32/stm32f429i-disco/configs/nxhello/defconfig
index ed2d24f34c..ff121d0803 100644
--- a/boards/arm/stm32/stm32f429i-disco/configs/nxhello/defconfig
+++ b/boards/arm/stm32/stm32f429i-disco/configs/nxhello/defconfig
@@ -33,6 +33,7 @@ CONFIG_HEAP2_BASE=0xD0000000
 CONFIG_HEAP2_SIZE=8388608
 CONFIG_INIT_ENTRYPOINT="nsh_main"
 CONFIG_INTELHEX_BINARY=y
+CONFIG_LIBC_MAX_EXITFUNS=1
 CONFIG_MM_REGIONS=3
 CONFIG_MQ_MAXMSGSIZE=64
 CONFIG_NSH_ARCHINIT=y
@@ -51,7 +52,6 @@ CONFIG_RAM_START=0x20000000
 CONFIG_RAW_BINARY=y
 CONFIG_RR_INTERVAL=200
 CONFIG_SCHED_HPWORK=y
-CONFIG_SCHED_ONEXIT=y
 CONFIG_SCHED_WAITPID=y
 CONFIG_START_DAY=7
 CONFIG_START_MONTH=2
diff --git a/boards/arm/stm32/stm32f429i-disco/configs/nxwm/defconfig b/boards/arm/stm32/stm32f429i-disco/configs/nxwm/defconfig
index 45f09c2ae2..007cfa1410 100644
--- a/boards/arm/stm32/stm32f429i-disco/configs/nxwm/defconfig
+++ b/boards/arm/stm32/stm32f429i-disco/configs/nxwm/defconfig
@@ -38,6 +38,7 @@ CONFIG_INIT_ENTRYPOINT="nxwm_main"
 CONFIG_INPUT=y
 CONFIG_INPUT_STMPE811=y
 CONFIG_INTELHEX_BINARY=y
+CONFIG_LIBC_MAX_EXITFUNS=1
 CONFIG_MM_REGIONS=2
 CONFIG_MQ_MAXMSGSIZE=64
 CONFIG_NSH_ARCHINIT=y
@@ -87,7 +88,6 @@ CONFIG_RAW_BINARY=y
 CONFIG_RR_INTERVAL=200
 CONFIG_SCHED_HPWORK=y
 CONFIG_SCHED_HPWORKPRIORITY=192
-CONFIG_SCHED_ONEXIT=y
 CONFIG_SCHED_WAITPID=y
 CONFIG_START_DAY=15
 CONFIG_START_MONTH=11
diff --git a/boards/arm/stm32/stm32f4discovery/configs/cxxtest/defconfig b/boards/arm/stm32/stm32f4discovery/configs/cxxtest/defconfig
index f7d6d8ce3a..7ff72a672f 100644
--- a/boards/arm/stm32/stm32f4discovery/configs/cxxtest/defconfig
+++ b/boards/arm/stm32/stm32f4discovery/configs/cxxtest/defconfig
@@ -20,6 +20,7 @@ CONFIG_HAVE_CXX=y
 CONFIG_HOST_WINDOWS=y
 CONFIG_INIT_ENTRYPOINT="cxxtest_main"
 CONFIG_INTELHEX_BINARY=y
+CONFIG_LIBC_MAX_EXITFUNS=4
 CONFIG_LIBM=y
 CONFIG_MM_REGIONS=2
 CONFIG_PREALLOC_TIMERS=4
@@ -27,8 +28,6 @@ CONFIG_RAM_SIZE=114688
 CONFIG_RAM_START=0x20000000
 CONFIG_RAW_BINARY=y
 CONFIG_RR_INTERVAL=200
-CONFIG_SCHED_ONEXIT=y
-CONFIG_SCHED_ONEXIT_MAX=4
 CONFIG_START_DAY=2
 CONFIG_START_MONTH=11
 CONFIG_START_YEAR=2012
diff --git a/boards/arm/stm32/stm32f4discovery/configs/testlibcxx/defconfig b/boards/arm/stm32/stm32f4discovery/configs/testlibcxx/defconfig
index a3dd31dee4..f5d24ebb9d 100644
--- a/boards/arm/stm32/stm32f4discovery/configs/testlibcxx/defconfig
+++ b/boards/arm/stm32/stm32f4discovery/configs/testlibcxx/defconfig
@@ -25,6 +25,7 @@ CONFIG_LIBCXX=y
 CONFIG_LIBCXXABI=y
 CONFIG_LIBC_FLOATINGPOINT=y
 CONFIG_LIBC_LOCALTIME=y
+CONFIG_LIBC_MAX_EXITFUNS=4
 CONFIG_LIBM=y
 CONFIG_MM_REGIONS=2
 CONFIG_NSH_BUILTIN_APPS=y
@@ -34,8 +35,6 @@ CONFIG_RAM_SIZE=114688
 CONFIG_RAM_START=0x20000000
 CONFIG_RAW_BINARY=y
 CONFIG_RR_INTERVAL=200
-CONFIG_SCHED_ONEXIT=y
-CONFIG_SCHED_ONEXIT_MAX=4
 CONFIG_SCHED_WAITPID=y
 CONFIG_START_DAY=2
 CONFIG_START_MONTH=11
diff --git a/boards/arm/stm32f7/stm32f746g-disco/configs/netnsh/defconfig b/boards/arm/stm32f7/stm32f746g-disco/configs/netnsh/defconfig
index 22eba1869e..1c1d102423 100644
--- a/boards/arm/stm32f7/stm32f746g-disco/configs/netnsh/defconfig
+++ b/boards/arm/stm32f7/stm32f746g-disco/configs/netnsh/defconfig
@@ -30,6 +30,7 @@ CONFIG_HAVE_CXXINITIALIZE=y
 CONFIG_INIT_ENTRYPOINT="nsh_main"
 CONFIG_INTELHEX_BINARY=y
 CONFIG_LIBC_HOSTNAME="stntest"
+CONFIG_LIBC_MAX_EXITFUNS=1
 CONFIG_MM_REGIONS=3
 CONFIG_NET=y
 CONFIG_NETDB_DNSCLIENT=y
@@ -60,7 +61,6 @@ CONFIG_RAM_SIZE=245760
 CONFIG_RAM_START=0x20010000
 CONFIG_RAW_BINARY=y
 CONFIG_RR_INTERVAL=20
-CONFIG_SCHED_ATEXIT=y
 CONFIG_SCHED_HPWORK=y
 CONFIG_SCHED_WAITPID=y
 CONFIG_START_DAY=14
diff --git a/boards/risc-v/bl602/bl602evb/configs/wifi/defconfig b/boards/risc-v/bl602/bl602evb/configs/wifi/defconfig
index e5fa4e0380..c815b1d85e 100644
--- a/boards/risc-v/bl602/bl602evb/configs/wifi/defconfig
+++ b/boards/risc-v/bl602/bl602evb/configs/wifi/defconfig
@@ -62,6 +62,7 @@ CONFIG_IOB_THROTTLE=10
 CONFIG_LIBCXX=y
 CONFIG_LIBCXXABI=y
 CONFIG_LIBC_LOCALTIME=y
+CONFIG_LIBC_MAX_EXITFUNS=1
 CONFIG_LIBC_PERROR_STDOUT=y
 CONFIG_LIBC_STRERROR=y
 CONFIG_LIBM=y
@@ -105,7 +106,6 @@ CONFIG_RAM_START=0xc0800000
 CONFIG_RAW_BINARY=y
 CONFIG_READLINE_CMD_HISTORY=y
 CONFIG_RR_INTERVAL=200
-CONFIG_SCHED_ATEXIT=y
 CONFIG_SCHED_HAVE_PARENT=y
 CONFIG_SCHED_HPWORK=y
 CONFIG_SCHED_HPWORKSTACKSIZE=2040
diff --git a/boards/risc-v/esp32c3/esp32c3-devkit/configs/autopm/defconfig b/boards/risc-v/esp32c3/esp32c3-devkit/configs/autopm/defconfig
index eade6df08a..d12891677f 100644
--- a/boards/risc-v/esp32c3/esp32c3-devkit/configs/autopm/defconfig
+++ b/boards/risc-v/esp32c3/esp32c3-devkit/configs/autopm/defconfig
@@ -31,6 +31,7 @@ CONFIG_IDLETHREAD_STACKSIZE=3072
 CONFIG_INIT_ENTRYPOINT="nsh_main"
 CONFIG_INTELHEX_BINARY=y
 CONFIG_LIBC_FLOATINGPOINT=y
+CONFIG_LIBC_MAX_EXITFUNS=1
 CONFIG_NAME_MAX=48
 CONFIG_NETDB_DNSCLIENT=y
 CONFIG_NETDEV_LATEINIT=y
diff --git a/boards/risc-v/esp32c3/esp32c3-devkit/configs/cxx/defconfig b/boards/risc-v/esp32c3/esp32c3-devkit/configs/cxx/defconfig
index 6b8729b3c4..1e54ba06dc 100644
--- a/boards/risc-v/esp32c3/esp32c3-devkit/configs/cxx/defconfig
+++ b/boards/risc-v/esp32c3/esp32c3-devkit/configs/cxx/defconfig
@@ -27,6 +27,7 @@ CONFIG_INIT_ENTRYPOINT="nsh_main"
 CONFIG_INTELHEX_BINARY=y
 CONFIG_LIBCXX=y
 CONFIG_LIBCXXABI=y
+CONFIG_LIBC_MAX_EXITFUNS=1
 CONFIG_LIBC_PERROR_STDOUT=y
 CONFIG_LIBC_STRERROR=y
 CONFIG_LIBM=y
@@ -39,7 +40,6 @@ CONFIG_NSH_STRERROR=y
 CONFIG_PREALLOC_TIMERS=0
 CONFIG_RAW_BINARY=y
 CONFIG_RR_INTERVAL=200
-CONFIG_SCHED_ATEXIT=y
 CONFIG_SCHED_WAITPID=y
 CONFIG_START_DAY=29
 CONFIG_START_MONTH=11
diff --git a/boards/risc-v/esp32c3/esp32c3-devkit/configs/sta_softap/defconfig b/boards/risc-v/esp32c3/esp32c3-devkit/configs/sta_softap/defconfig
index b3f9a95acd..41ff7d52c1 100644
--- a/boards/risc-v/esp32c3/esp32c3-devkit/configs/sta_softap/defconfig
+++ b/boards/risc-v/esp32c3/esp32c3-devkit/configs/sta_softap/defconfig
@@ -44,6 +44,7 @@ CONFIG_IDLETHREAD_STACKSIZE=3072
 CONFIG_INIT_ENTRYPOINT="nsh_main"
 CONFIG_INTELHEX_BINARY=y
 CONFIG_LIBC_FLOATINGPOINT=y
+CONFIG_LIBC_MAX_EXITFUNS=1
 CONFIG_MM_REGIONS=3
 CONFIG_NETDB_DNSCLIENT=y
 CONFIG_NETDEV_LATEINIT=y
diff --git a/boards/risc-v/esp32c3/esp32c3-devkit/configs/wapi/defconfig b/boards/risc-v/esp32c3/esp32c3-devkit/configs/wapi/defconfig
index 82aa22dbb8..f97493862e 100644
--- a/boards/risc-v/esp32c3/esp32c3-devkit/configs/wapi/defconfig
+++ b/boards/risc-v/esp32c3/esp32c3-devkit/configs/wapi/defconfig
@@ -29,6 +29,7 @@ CONFIG_IDLETHREAD_STACKSIZE=3072
 CONFIG_INIT_ENTRYPOINT="nsh_main"
 CONFIG_INTELHEX_BINARY=y
 CONFIG_LIBC_FLOATINGPOINT=y
+CONFIG_LIBC_MAX_EXITFUNS=1
 CONFIG_NAME_MAX=48
 CONFIG_NETDB_DNSCLIENT=y
 CONFIG_NETDEV_LATEINIT=y
diff --git a/boards/risc-v/k210/maix-bit/configs/smp2/defconfig b/boards/risc-v/k210/maix-bit/configs/smp2/defconfig
index 0402600fb2..83d4eae8ee 100644
--- a/boards/risc-v/k210/maix-bit/configs/smp2/defconfig
+++ b/boards/risc-v/k210/maix-bit/configs/smp2/defconfig
@@ -29,6 +29,7 @@ CONFIG_IDLETHREAD_STACKSIZE=2048
 CONFIG_INIT_ENTRYPOINT="nsh_main"
 CONFIG_INIT_STACKSIZE=3072
 CONFIG_INTELHEX_BINARY=y
+CONFIG_LIBC_MAX_EXITFUNS=32
 CONFIG_LIBC_PERROR_STDOUT=y
 CONFIG_LIBC_STRERROR=y
 CONFIG_NSH_ARCHINIT=y
@@ -43,13 +44,10 @@ CONFIG_RAM_SIZE=2097152
 CONFIG_RAM_START=0x80400000
 CONFIG_RAW_BINARY=y
 CONFIG_READLINE_CMD_HISTORY=y
-CONFIG_SCHED_ATEXIT=y
 CONFIG_SCHED_CHILD_STATUS=y
 CONFIG_SCHED_HAVE_PARENT=y
 CONFIG_SCHED_INSTRUMENTATION=y
 CONFIG_SCHED_INSTRUMENTATION_SWITCH=y
-CONFIG_SCHED_ONEXIT=y
-CONFIG_SCHED_ONEXIT_MAX=32
 CONFIG_SCHED_STARTHOOK=y
 CONFIG_SMP=y
 CONFIG_SMP_NCPUS=2
diff --git a/boards/risc-v/mpfs/icicle/configs/knsh/defconfig b/boards/risc-v/mpfs/icicle/configs/knsh/defconfig
index b024092042..01f67a106c 100644
--- a/boards/risc-v/mpfs/icicle/configs/knsh/defconfig
+++ b/boards/risc-v/mpfs/icicle/configs/knsh/defconfig
@@ -55,6 +55,7 @@ CONFIG_INTELHEX_BINARY=y
 CONFIG_LIBC_EXECFUNCS=y
 CONFIG_LIBC_FLOATINGPOINT=y
 CONFIG_LIBC_HOSTNAME="icicle"
+CONFIG_LIBC_MAX_EXITFUNS=2
 CONFIG_LIBC_PERROR_STDOUT=y
 CONFIG_LIBC_STRERROR=y
 CONFIG_MEMSET_64BIT=y
@@ -81,8 +82,6 @@ CONFIG_RR_INTERVAL=200
 CONFIG_SCHED_HAVE_PARENT=y
 CONFIG_SCHED_HPWORK=y
 CONFIG_SCHED_LPWORK=y
-CONFIG_SCHED_ONEXIT=y
-CONFIG_SCHED_ONEXIT_MAX=2
 CONFIG_SCHED_WAITPID=y
 CONFIG_SERIAL_NPOLLWAITERS=2
 CONFIG_STACK_COLORATION=y
diff --git a/boards/sim/sim/sim/configs/alsa/defconfig b/boards/sim/sim/sim/configs/alsa/defconfig
index 470298127f..d23aaee021 100644
--- a/boards/sim/sim/sim/configs/alsa/defconfig
+++ b/boards/sim/sim/sim/configs/alsa/defconfig
@@ -34,6 +34,7 @@ CONFIG_IDLETHREAD_STACKSIZE=4096
 CONFIG_INIT_ENTRYPOINT="nsh_main"
 CONFIG_LIBC_ENVPATH=y
 CONFIG_LIBC_EXECFUNCS=y
+CONFIG_LIBC_MAX_EXITFUNS=1
 CONFIG_NSH_ARCHINIT=y
 CONFIG_NSH_ARCHROMFS=y
 CONFIG_NSH_BUILTIN_APPS=y
@@ -46,7 +47,6 @@ CONFIG_PATH_INITIAL="/bin"
 CONFIG_POSIX_SPAWN_PROXY_STACKSIZE=2048
 CONFIG_READLINE_TABCOMPLETION=y
 CONFIG_SCHED_HAVE_PARENT=y
-CONFIG_SCHED_ONEXIT=y
 CONFIG_SCHED_WAITPID=y
 CONFIG_SIM_HOSTFS=y
 CONFIG_START_MONTH=6
diff --git a/boards/sim/sim/sim/configs/asan/defconfig b/boards/sim/sim/sim/configs/asan/defconfig
index f523a564e0..3cc226cbc2 100644
--- a/boards/sim/sim/sim/configs/asan/defconfig
+++ b/boards/sim/sim/sim/configs/asan/defconfig
@@ -25,6 +25,7 @@ CONFIG_FS_NAMED_SEMAPHORES=y
 CONFIG_FS_PROCFS=y
 CONFIG_INIT_ARGS="\"-c\", \"ostest;poweroff\""
 CONFIG_INIT_ENTRYPOINT="nsh_main"
+CONFIG_LIBC_MAX_EXITFUNS=1
 CONFIG_MM_CUSTOMIZE_MANAGER=y
 CONFIG_NSH_ARCHINIT=y
 CONFIG_NSH_BUILTIN_APPS=y
@@ -36,7 +37,6 @@ CONFIG_READLINE_TABCOMPLETION=y
 CONFIG_RR_INTERVAL=10
 CONFIG_SCHED_HAVE_PARENT=y
 CONFIG_SCHED_LPWORK=y
-CONFIG_SCHED_ONEXIT=y
 CONFIG_SCHED_WAITPID=y
 CONFIG_SIG_DEFAULT=y
 CONFIG_SIG_EVTHREAD=y
diff --git a/boards/sim/sim/sim/configs/bas/defconfig b/boards/sim/sim/sim/configs/bas/defconfig
index 794eccc179..ca916c87d6 100644
--- a/boards/sim/sim/sim/configs/bas/defconfig
+++ b/boards/sim/sim/sim/configs/bas/defconfig
@@ -25,6 +25,7 @@ CONFIG_INIT_ENTRYPOINT="nsh_main"
 CONFIG_INTERPRETERS_BAS=y
 CONFIG_LIBC_ENVPATH=y
 CONFIG_LIBC_EXECFUNCS=y
+CONFIG_LIBC_MAX_EXITFUNS=1
 CONFIG_LIBM=y
 CONFIG_NSH_ARCHINIT=y
 CONFIG_NSH_BUILTIN_APPS=y
@@ -35,7 +36,6 @@ CONFIG_NSH_ROMFSDEVNO=1
 CONFIG_NSH_ROMFSETC=y
 CONFIG_PATH_INITIAL="/bin"
 CONFIG_SCHED_HAVE_PARENT=y
-CONFIG_SCHED_ONEXIT=y
 CONFIG_SCHED_WAITPID=y
 CONFIG_START_MONTH=6
 CONFIG_START_YEAR=2008
diff --git a/boards/sim/sim/sim/configs/bastest/defconfig b/boards/sim/sim/sim/configs/bastest/defconfig
index e0a6f74d82..22d7d25759 100644
--- a/boards/sim/sim/sim/configs/bastest/defconfig
+++ b/boards/sim/sim/sim/configs/bastest/defconfig
@@ -36,6 +36,7 @@ CONFIG_INIT_ENTRYPOINT="nsh_main"
 CONFIG_INTERPRETERS_BAS=y
 CONFIG_LIBC_ENVPATH=y
 CONFIG_LIBC_EXECFUNCS=y
+CONFIG_LIBC_MAX_EXITFUNS=1
 CONFIG_LIBC_STRERROR=y
 CONFIG_LIBM=y
 CONFIG_NSH_ARCHINIT=y
@@ -53,7 +54,6 @@ CONFIG_PATH_INITIAL="/bin"
 CONFIG_POSIX_SPAWN_PROXY_STACKSIZE=2048
 CONFIG_READLINE_TABCOMPLETION=y
 CONFIG_SCHED_HAVE_PARENT=y
-CONFIG_SCHED_ONEXIT=y
 CONFIG_SCHED_WAITPID=y
 CONFIG_START_MONTH=6
 CONFIG_START_YEAR=2008
diff --git a/boards/sim/sim/sim/configs/bluetooth/defconfig b/boards/sim/sim/sim/configs/bluetooth/defconfig
index a73281ca71..9dcb2bed3d 100644
--- a/boards/sim/sim/sim/configs/bluetooth/defconfig
+++ b/boards/sim/sim/sim/configs/bluetooth/defconfig
@@ -39,6 +39,7 @@ CONFIG_INIT_ENTRYPOINT="nsh_main"
 CONFIG_LIBC_ENVPATH=y
 CONFIG_LIBC_EXECFUNCS=y
 CONFIG_LIBC_HOSTNAME="NuttX-SIM"
+CONFIG_LIBC_MAX_EXITFUNS=1
 CONFIG_NET=y
 CONFIG_NETDEVICES=y
 CONFIG_NETDEV_LATEINIT=y
@@ -59,7 +60,6 @@ CONFIG_POSIX_SPAWN_PROXY_STACKSIZE=2048
 CONFIG_PREALLOC_MQ_MSGS=64
 CONFIG_READLINE_TABCOMPLETION=y
 CONFIG_SCHED_HAVE_PARENT=y
-CONFIG_SCHED_ONEXIT=y
 CONFIG_SCHED_WAITPID=y
 CONFIG_START_DAY=3
 CONFIG_START_MONTH=4
diff --git a/boards/sim/sim/sim/configs/bthcisock/defconfig b/boards/sim/sim/sim/configs/bthcisock/defconfig
index dc8026733d..e9a855b0bc 100644
--- a/boards/sim/sim/sim/configs/bthcisock/defconfig
+++ b/boards/sim/sim/sim/configs/bthcisock/defconfig
@@ -40,6 +40,7 @@ CONFIG_INIT_ENTRYPOINT="nsh_main"
 CONFIG_LIBC_ENVPATH=y
 CONFIG_LIBC_EXECFUNCS=y
 CONFIG_LIBC_HOSTNAME="NuttX-SIM"
+CONFIG_LIBC_MAX_EXITFUNS=1
 CONFIG_NET=y
 CONFIG_NETDEVICES=y
 CONFIG_NETDEV_LATEINIT=y
@@ -60,7 +61,6 @@ CONFIG_POSIX_SPAWN_PROXY_STACKSIZE=2048
 CONFIG_PREALLOC_MQ_MSGS=64
 CONFIG_READLINE_TABCOMPLETION=y
 CONFIG_SCHED_HAVE_PARENT=y
-CONFIG_SCHED_ONEXIT=y
 CONFIG_SCHED_WAITPID=y
 CONFIG_SIM_HCISOCKET=y
 CONFIG_START_DAY=3
diff --git a/boards/sim/sim/sim/configs/cxxtest/defconfig b/boards/sim/sim/sim/configs/cxxtest/defconfig
index 92a2250aff..3ddc6cfe57 100644
--- a/boards/sim/sim/sim/configs/cxxtest/defconfig
+++ b/boards/sim/sim/sim/configs/cxxtest/defconfig
@@ -16,11 +16,10 @@ CONFIG_CXX_RTTI=y
 CONFIG_HAVE_CXX=y
 CONFIG_IDLETHREAD_STACKSIZE=4096
 CONFIG_INIT_ENTRYPOINT="cxxtest_main"
+CONFIG_LIBC_MAX_EXITFUNS=4
 CONFIG_LIBM=y
 CONFIG_PTHREAD_MUTEX_TYPES=y
 CONFIG_RAM_START=0x00000000
-CONFIG_SCHED_ONEXIT=y
-CONFIG_SCHED_ONEXIT_MAX=4
 CONFIG_START_DAY=27
 CONFIG_START_MONTH=2
 CONFIG_START_YEAR=2007
diff --git a/boards/sim/sim/sim/configs/duktape/defconfig b/boards/sim/sim/sim/configs/duktape/defconfig
index 3adc958456..584a3a9e1a 100644
--- a/boards/sim/sim/sim/configs/duktape/defconfig
+++ b/boards/sim/sim/sim/configs/duktape/defconfig
@@ -34,6 +34,7 @@ CONFIG_INTERPRETERS_DUKTAPE=y
 CONFIG_INTERPRETERS_DUKTAPE_STACKSIZE=32768
 CONFIG_LIBC_ENVPATH=y
 CONFIG_LIBC_EXECFUNCS=y
+CONFIG_LIBC_MAX_EXITFUNS=1
 CONFIG_LIBM=y
 CONFIG_NSH_ARCHINIT=y
 CONFIG_NSH_ARCHROMFS=y
@@ -50,7 +51,6 @@ CONFIG_PATH_INITIAL="/bin"
 CONFIG_POSIX_SPAWN_PROXY_STACKSIZE=2048
 CONFIG_READLINE_TABCOMPLETION=y
 CONFIG_SCHED_HAVE_PARENT=y
-CONFIG_SCHED_ONEXIT=y
 CONFIG_SCHED_WAITPID=y
 CONFIG_START_MONTH=6
 CONFIG_START_YEAR=2008
diff --git a/boards/sim/sim/sim/configs/dynconns/defconfig b/boards/sim/sim/sim/configs/dynconns/defconfig
index 051a595545..bacb295bf9 100644
--- a/boards/sim/sim/sim/configs/dynconns/defconfig
+++ b/boards/sim/sim/sim/configs/dynconns/defconfig
@@ -27,6 +27,7 @@ CONFIG_INIT_ENTRYPOINT="nsh_main"
 CONFIG_IOB_NOTIFIER=y
 CONFIG_LIBC_DLFCN=y
 CONFIG_LIBC_ENVPATH=y
+CONFIG_LIBC_MAX_EXITFUNS=1
 CONFIG_LIBC_STRERROR=y
 CONFIG_MM_FILL_ALLOCATIONS=y
 CONFIG_NAME_MAX=64
@@ -70,7 +71,6 @@ CONFIG_RTC_ARCH=y
 CONFIG_RTC_DATETIME=y
 CONFIG_RTC_DRIVER=y
 CONFIG_SCHED_HAVE_PARENT=y
-CONFIG_SCHED_ONEXIT=y
 CONFIG_SCHED_WAITPID=y
 CONFIG_SIG_DEFAULT=y
 CONFIG_SIM_NETDEV=y
diff --git a/boards/sim/sim/sim/configs/elf/defconfig b/boards/sim/sim/sim/configs/elf/defconfig
index 5c5f80727d..68b95452f2 100644
--- a/boards/sim/sim/sim/configs/elf/defconfig
+++ b/boards/sim/sim/sim/configs/elf/defconfig
@@ -37,6 +37,7 @@ CONFIG_FS_ROMFS=y
 CONFIG_IDLETHREAD_STACKSIZE=4096
 CONFIG_INIT_ENTRYPOINT="nsh_main"
 CONFIG_LIBC_ENVPATH=y
+CONFIG_LIBC_MAX_EXITFUNS=1
 CONFIG_LIBC_STRERROR=y
 CONFIG_NSH_ARCHINIT=y
 CONFIG_NSH_BUILTIN_APPS=y
@@ -48,7 +49,6 @@ CONFIG_PATH_INITIAL="/bin"
 CONFIG_POSIX_SPAWN_PROXY_STACKSIZE=2048
 CONFIG_READLINE_TABCOMPLETION=y
 CONFIG_SCHED_HAVE_PARENT=y
-CONFIG_SCHED_ONEXIT=y
 CONFIG_SCHED_WAITPID=y
 CONFIG_START_MONTH=6
 CONFIG_START_YEAR=2008
diff --git a/boards/sim/sim/sim/configs/foc/defconfig b/boards/sim/sim/sim/configs/foc/defconfig
index 5c8bbbbeb0..eff9c72a11 100644
--- a/boards/sim/sim/sim/configs/foc/defconfig
+++ b/boards/sim/sim/sim/configs/foc/defconfig
@@ -61,6 +61,7 @@ CONFIG_INIT_ENTRYPOINT="nsh_main"
 CONFIG_LIBC_ENVPATH=y
 CONFIG_LIBC_EXECFUNCS=y
 CONFIG_LIBC_FLOATINGPOINT=y
+CONFIG_LIBC_MAX_EXITFUNS=1
 CONFIG_LIBM=y
 CONFIG_MOTOR=y
 CONFIG_MOTOR_FOC=y
@@ -81,7 +82,6 @@ CONFIG_POSIX_SPAWN_PROXY_STACKSIZE=2048
 CONFIG_READLINE_TABCOMPLETION=y
 CONFIG_SCHED_HAVE_PARENT=y
 CONFIG_SCHED_HPWORK=y
-CONFIG_SCHED_ONEXIT=y
 CONFIG_SCHED_SPORADIC=y
 CONFIG_SCHED_WAITPID=y
 CONFIG_START_MONTH=6
diff --git a/boards/sim/sim/sim/configs/ipforward/defconfig b/boards/sim/sim/sim/configs/ipforward/defconfig
index 5e76c4fb18..aa9a60f840 100644
--- a/boards/sim/sim/sim/configs/ipforward/defconfig
+++ b/boards/sim/sim/sim/configs/ipforward/defconfig
@@ -35,6 +35,7 @@ CONFIG_INIT_ENTRYPOINT="nsh_main"
 CONFIG_LIBC_ENVPATH=y
 CONFIG_LIBC_EXECFUNCS=y
 CONFIG_LIBC_HOSTNAME="IP-Forward"
+CONFIG_LIBC_MAX_EXITFUNS=1
 CONFIG_NET=y
 CONFIG_NETDEVICES=y
 CONFIG_NET_IPFORWARD=y
@@ -60,7 +61,6 @@ CONFIG_READLINE_TABCOMPLETION=y
 CONFIG_SCHED_HAVE_PARENT=y
 CONFIG_SCHED_LPWORK=y
 CONFIG_SCHED_LPWORKPRIORITY=140
-CONFIG_SCHED_ONEXIT=y
 CONFIG_SCHED_WAITPID=y
 CONFIG_START_MONTH=6
 CONFIG_START_YEAR=2008
diff --git a/boards/sim/sim/sim/configs/kasan/defconfig b/boards/sim/sim/sim/configs/kasan/defconfig
index 37b1a25ff6..caa7c74129 100644
--- a/boards/sim/sim/sim/configs/kasan/defconfig
+++ b/boards/sim/sim/sim/configs/kasan/defconfig
@@ -25,6 +25,7 @@ CONFIG_FS_NAMED_SEMAPHORES=y
 CONFIG_FS_PROCFS=y
 CONFIG_INIT_ARGS="\"-c\", \"ostest;gcov -d;poweroff\""
 CONFIG_INIT_ENTRYPOINT="nsh_main"
+CONFIG_LIBC_MAX_EXITFUNS=1
 CONFIG_MM_KASAN=y
 CONFIG_NSH_ARCHINIT=y
 CONFIG_NSH_BUILTIN_APPS=y
@@ -36,7 +37,6 @@ CONFIG_READLINE_TABCOMPLETION=y
 CONFIG_RR_INTERVAL=10
 CONFIG_SCHED_HAVE_PARENT=y
 CONFIG_SCHED_LPWORK=y
-CONFIG_SCHED_ONEXIT=y
 CONFIG_SCHED_WAITPID=y
 CONFIG_SIG_DEFAULT=y
 CONFIG_SIG_EVTHREAD=y
diff --git a/boards/sim/sim/sim/configs/libcxxtest/defconfig b/boards/sim/sim/sim/configs/libcxxtest/defconfig
index d867438364..f21baaa250 100644
--- a/boards/sim/sim/sim/configs/libcxxtest/defconfig
+++ b/boards/sim/sim/sim/configs/libcxxtest/defconfig
@@ -47,6 +47,7 @@ CONFIG_LIBCXX=y
 CONFIG_LIBCXXABI=y
 CONFIG_LIBC_ENVPATH=y
 CONFIG_LIBC_EXECFUNCS=y
+CONFIG_LIBC_MAX_EXITFUNS=1
 CONFIG_MM_FILL_ALLOCATIONS=y
 CONFIG_NET=y
 CONFIG_NETDB_DNSCLIENT=y
@@ -85,7 +86,6 @@ CONFIG_RTC_ARCH=y
 CONFIG_RTC_DATETIME=y
 CONFIG_RTC_DRIVER=y
 CONFIG_SCHED_HAVE_PARENT=y
-CONFIG_SCHED_ONEXIT=y
 CONFIG_SCHED_WAITPID=y
 CONFIG_SIM_HOSTFS=y
 CONFIG_SIM_NETDEV=y
diff --git a/boards/sim/sim/sim/configs/linuxi2c/defconfig b/boards/sim/sim/sim/configs/linuxi2c/defconfig
index e36ddadcf0..8086d9429a 100644
--- a/boards/sim/sim/sim/configs/linuxi2c/defconfig
+++ b/boards/sim/sim/sim/configs/linuxi2c/defconfig
@@ -24,13 +24,13 @@ CONFIG_FS_PROCFS=y
 CONFIG_IDLETHREAD_STACKSIZE=4096
 CONFIG_INIT_ENTRYPOINT="nsh_main"
 CONFIG_LIBC_EXECFUNCS=y
+CONFIG_LIBC_MAX_EXITFUNS=1
 CONFIG_NSH_ARCHINIT=y
 CONFIG_NSH_BUILTIN_APPS=y
 CONFIG_NSH_READLINE=y
 CONFIG_POSIX_SPAWN_PROXY_STACKSIZE=2048
 CONFIG_READLINE_TABCOMPLETION=y
 CONFIG_SCHED_HAVE_PARENT=y
-CONFIG_SCHED_ONEXIT=y
 CONFIG_SCHED_WAITPID=y
 CONFIG_SIM_I2CBUS=y
 CONFIG_START_MONTH=6
diff --git a/boards/sim/sim/sim/configs/linuxspi/defconfig b/boards/sim/sim/sim/configs/linuxspi/defconfig
index 8c41bb6e38..1febcbf165 100644
--- a/boards/sim/sim/sim/configs/linuxspi/defconfig
+++ b/boards/sim/sim/sim/configs/linuxspi/defconfig
@@ -24,13 +24,13 @@ CONFIG_FS_PROCFS=y
 CONFIG_IDLETHREAD_STACKSIZE=4096
 CONFIG_INIT_ENTRYPOINT="nsh_main"
 CONFIG_LIBC_EXECFUNCS=y
+CONFIG_LIBC_MAX_EXITFUNS=1
 CONFIG_NSH_ARCHINIT=y
 CONFIG_NSH_BUILTIN_APPS=y
 CONFIG_NSH_READLINE=y
 CONFIG_POSIX_SPAWN_PROXY_STACKSIZE=2048
 CONFIG_READLINE_TABCOMPLETION=y
 CONFIG_SCHED_HAVE_PARENT=y
-CONFIG_SCHED_ONEXIT=y
 CONFIG_SCHED_WAITPID=y
 CONFIG_SIM_SPI=y
 CONFIG_START_MONTH=6
diff --git a/boards/sim/sim/sim/configs/loadable/defconfig b/boards/sim/sim/sim/configs/loadable/defconfig
index a4b698f682..a40d42c135 100644
--- a/boards/sim/sim/sim/configs/loadable/defconfig
+++ b/boards/sim/sim/sim/configs/loadable/defconfig
@@ -35,6 +35,7 @@ CONFIG_INIT_MOUNT_SOURCE=""
 CONFIG_INIT_MOUNT_TARGET="/system"
 CONFIG_LIBC_ENVPATH=y
 CONFIG_LIBC_EXECFUNCS=y
+CONFIG_LIBC_MAX_EXITFUNS=1
 CONFIG_MEMSET_OPTSPEED=y
 CONFIG_NSH_ARCHINIT=y
 CONFIG_NSH_BUILTIN_APPS=y
@@ -44,7 +45,6 @@ CONFIG_PATH_INITIAL="/system/bin"
 CONFIG_READLINE_CMD_HISTORY=y
 CONFIG_READLINE_TABCOMPLETION=y
 CONFIG_SCHED_HAVE_PARENT=y
-CONFIG_SCHED_ONEXIT=y
 CONFIG_SCHED_WAITPID=y
 CONFIG_SIM_HOSTFS=y
 CONFIG_START_MONTH=6
diff --git a/boards/sim/sim/sim/configs/lua/defconfig b/boards/sim/sim/sim/configs/lua/defconfig
index f73826f231..cfb04679ab 100644
--- a/boards/sim/sim/sim/configs/lua/defconfig
+++ b/boards/sim/sim/sim/configs/lua/defconfig
@@ -38,6 +38,7 @@ CONFIG_LIBC_EXECFUNCS=y
 CONFIG_LIBC_FLOATINGPOINT=y
 CONFIG_LIBC_LOCALE_CATALOG=y
 CONFIG_LIBC_LOCALE_GETTEXT=y
+CONFIG_LIBC_MAX_EXITFUNS=1
 CONFIG_LIBM=y
 CONFIG_NSH_ARCHINIT=y
 CONFIG_NSH_ARCHROMFS=y
@@ -55,7 +56,6 @@ CONFIG_READLINE_CMD_HISTORY=y
 CONFIG_READLINE_TABCOMPLETION=y
 CONFIG_SCHED_HAVE_PARENT=y
 CONFIG_SCHED_HPWORK=y
-CONFIG_SCHED_ONEXIT=y
 CONFIG_SERIAL_TERMIOS=y
 CONFIG_SIG_DEFAULT=y
 CONFIG_START_MONTH=6
diff --git a/boards/sim/sim/sim/configs/minibasic/defconfig b/boards/sim/sim/sim/configs/minibasic/defconfig
index 058ff9cf83..26688af091 100644
--- a/boards/sim/sim/sim/configs/minibasic/defconfig
+++ b/boards/sim/sim/sim/configs/minibasic/defconfig
@@ -32,6 +32,7 @@ CONFIG_INTERPRETERS_MINIBASIC=y
 CONFIG_INTERPRETER_MINIBASIC_TESTSCRIPT=y
 CONFIG_LIBC_ENVPATH=y
 CONFIG_LIBC_EXECFUNCS=y
+CONFIG_LIBC_MAX_EXITFUNS=1
 CONFIG_LIBM=y
 CONFIG_NSH_ARCHINIT=y
 CONFIG_NSH_ARCHROMFS=y
@@ -45,7 +46,6 @@ CONFIG_PATH_INITIAL="/bin"
 CONFIG_POSIX_SPAWN_PROXY_STACKSIZE=2048
 CONFIG_READLINE_TABCOMPLETION=y
 CONFIG_SCHED_HAVE_PARENT=y
-CONFIG_SCHED_ONEXIT=y
 CONFIG_SCHED_WAITPID=y
 CONFIG_START_MONTH=6
 CONFIG_START_YEAR=2008
diff --git a/boards/sim/sim/sim/configs/module/defconfig b/boards/sim/sim/sim/configs/module/defconfig
index eeaae3eb0b..37bdae5a39 100644
--- a/boards/sim/sim/sim/configs/module/defconfig
+++ b/boards/sim/sim/sim/configs/module/defconfig
@@ -29,6 +29,7 @@ CONFIG_INIT_ENTRYPOINT="nsh_main"
 CONFIG_IOB_NOTIFIER=y
 CONFIG_LIBC_DLFCN=y
 CONFIG_LIBC_ENVPATH=y
+CONFIG_LIBC_MAX_EXITFUNS=1
 CONFIG_LIBC_STRERROR=y
 CONFIG_MM_FILL_ALLOCATIONS=y
 CONFIG_NAME_MAX=64
@@ -65,7 +66,6 @@ CONFIG_RTC_ARCH=y
 CONFIG_RTC_DATETIME=y
 CONFIG_RTC_DRIVER=y
 CONFIG_SCHED_HAVE_PARENT=y
-CONFIG_SCHED_ONEXIT=y
 CONFIG_SCHED_WAITPID=y
 CONFIG_SIG_DEFAULT=y
 CONFIG_SIM_NETDEV=y
diff --git a/boards/sim/sim/sim/configs/module32/defconfig b/boards/sim/sim/sim/configs/module32/defconfig
index b78d6fa7ef..4d891ae68e 100644
--- a/boards/sim/sim/sim/configs/module32/defconfig
+++ b/boards/sim/sim/sim/configs/module32/defconfig
@@ -29,6 +29,7 @@ CONFIG_INIT_ENTRYPOINT="nsh_main"
 CONFIG_IOB_NOTIFIER=y
 CONFIG_LIBC_DLFCN=y
 CONFIG_LIBC_ENVPATH=y
+CONFIG_LIBC_MAX_EXITFUNS=1
 CONFIG_LIBC_STRERROR=y
 CONFIG_MM_FILL_ALLOCATIONS=y
 CONFIG_NAME_MAX=64
@@ -64,7 +65,6 @@ CONFIG_RTC_ARCH=y
 CONFIG_RTC_DATETIME=y
 CONFIG_RTC_DRIVER=y
 CONFIG_SCHED_HAVE_PARENT=y
-CONFIG_SCHED_ONEXIT=y
 CONFIG_SCHED_WAITPID=y
 CONFIG_SIG_DEFAULT=y
 CONFIG_SIM_M32=y
diff --git a/boards/sim/sim/sim/configs/nimble/defconfig b/boards/sim/sim/sim/configs/nimble/defconfig
index 0567388a32..8998f15fff 100644
--- a/boards/sim/sim/sim/configs/nimble/defconfig
+++ b/boards/sim/sim/sim/configs/nimble/defconfig
@@ -41,6 +41,7 @@ CONFIG_INIT_ENTRYPOINT="nsh_main"
 CONFIG_LIBC_ENVPATH=y
 CONFIG_LIBC_EXECFUNCS=y
 CONFIG_LIBC_HOSTNAME="NuttX-SIM"
+CONFIG_LIBC_MAX_EXITFUNS=1
 CONFIG_NET=y
 CONFIG_NETDEVICES=y
 CONFIG_NETDEV_LATEINIT=y
@@ -64,7 +65,6 @@ CONFIG_PTHREAD_MUTEX_TYPES=y
 CONFIG_READLINE_TABCOMPLETION=y
 CONFIG_RR_INTERVAL=200
 CONFIG_SCHED_HAVE_PARENT=y
-CONFIG_SCHED_ONEXIT=y
 CONFIG_SCHED_WAITPID=y
 CONFIG_SIG_DEFAULT=y
 CONFIG_SIG_EVTHREAD=y
diff --git a/boards/sim/sim/sim/configs/note/defconfig b/boards/sim/sim/sim/configs/note/defconfig
index 66eeb472b1..0e736f53a9 100644
--- a/boards/sim/sim/sim/configs/note/defconfig
+++ b/boards/sim/sim/sim/configs/note/defconfig
@@ -22,6 +22,7 @@ CONFIG_EXAMPLES_HELLO=y
 CONFIG_FS_BINFS=y
 CONFIG_FS_PROCFS=y
 CONFIG_INIT_ENTRYPOINT="nsh_main"
+CONFIG_LIBC_MAX_EXITFUNS=1
 CONFIG_NSH_ARCHINIT=y
 CONFIG_NSH_BUILTIN_APPS=y
 CONFIG_NSH_READLINE=y
@@ -33,6 +34,5 @@ CONFIG_SCHED_INSTRUMENTATION_IRQHANDLER=y
 CONFIG_SCHED_INSTRUMENTATION_PREEMPTION=y
 CONFIG_SCHED_INSTRUMENTATION_SPINLOCKS=y
 CONFIG_SCHED_INSTRUMENTATION_SWITCH=y
-CONFIG_SCHED_ONEXIT=y
 CONFIG_SCHED_WAITPID=y
 CONFIG_SYSTEM_NSH=y
diff --git a/boards/sim/sim/sim/configs/nsh/defconfig b/boards/sim/sim/sim/configs/nsh/defconfig
index a59ef3b581..f139a7a978 100644
--- a/boards/sim/sim/sim/configs/nsh/defconfig
+++ b/boards/sim/sim/sim/configs/nsh/defconfig
@@ -42,6 +42,7 @@ CONFIG_LIBC_EXECFUNCS=y
 CONFIG_LIBC_LOCALE=y
 CONFIG_LIBC_LOCALE_CATALOG=y
 CONFIG_LIBC_LOCALE_GETTEXT=y
+CONFIG_LIBC_MAX_EXITFUNS=1
 CONFIG_LIBC_NUMBERED_ARGS=y
 CONFIG_NSH_ARCHINIT=y
 CONFIG_NSH_ARCHROMFS=y
@@ -62,7 +63,6 @@ CONFIG_READLINE_TABCOMPLETION=y
 CONFIG_SCHED_BACKTRACE=y
 CONFIG_SCHED_HAVE_PARENT=y
 CONFIG_SCHED_HPWORK=y
-CONFIG_SCHED_ONEXIT=y
 CONFIG_SCHED_WAITPID=y
 CONFIG_START_MONTH=6
 CONFIG_START_YEAR=2008
diff --git a/boards/sim/sim/sim/configs/nshcromfs/defconfig b/boards/sim/sim/sim/configs/nshcromfs/defconfig
index 51d3168110..eecf3e255b 100644
--- a/boards/sim/sim/sim/configs/nshcromfs/defconfig
+++ b/boards/sim/sim/sim/configs/nshcromfs/defconfig
@@ -33,6 +33,7 @@ CONFIG_IDLETHREAD_STACKSIZE=4096
 CONFIG_INIT_ENTRYPOINT="nsh_main"
 CONFIG_LIBC_ENVPATH=y
 CONFIG_LIBC_EXECFUNCS=y
+CONFIG_LIBC_MAX_EXITFUNS=1
 CONFIG_NSH_ARCHINIT=y
 CONFIG_NSH_BUILTIN_APPS=y
 CONFIG_NSH_FILE_APPS=y
@@ -41,7 +42,6 @@ CONFIG_PATH_INITIAL="/bin"
 CONFIG_POSIX_SPAWN_PROXY_STACKSIZE=2048
 CONFIG_READLINE_TABCOMPLETION=y
 CONFIG_SCHED_HAVE_PARENT=y
-CONFIG_SCHED_ONEXIT=y
 CONFIG_START_MONTH=6
 CONFIG_START_YEAR=2008
 CONFIG_SYSTEM_LZF=y
diff --git a/boards/sim/sim/sim/configs/nxlines/defconfig b/boards/sim/sim/sim/configs/nxlines/defconfig
index e5a871f740..b1c7bdc2aa 100644
--- a/boards/sim/sim/sim/configs/nxlines/defconfig
+++ b/boards/sim/sim/sim/configs/nxlines/defconfig
@@ -32,6 +32,7 @@ CONFIG_FS_ROMFS=y
 CONFIG_HAVE_CXX=y
 CONFIG_IDLETHREAD_STACKSIZE=8192
 CONFIG_INIT_ENTRYPOINT="nxlines_main"
+CONFIG_LIBC_MAX_EXITFUNS=1
 CONFIG_MQ_MAXMSGSIZE=64
 CONFIG_NSH_ARCHINIT=y
 CONFIG_NSH_FATDEVNO=2
@@ -48,7 +49,6 @@ CONFIG_NXTK_BORDERCOLOR3=0x00f8f8f8
 CONFIG_NX_BLOCKING=y
 CONFIG_NX_KBD=y
 CONFIG_NX_XYINPUT_MOUSE=y
-CONFIG_SCHED_ONEXIT=y
 CONFIG_SCHED_WAITPID=y
 CONFIG_SIM_FBBPP=32
 CONFIG_SIM_X11FB=y
diff --git a/boards/sim/sim/sim/configs/nxwm/defconfig b/boards/sim/sim/sim/configs/nxwm/defconfig
index 90c08bce04..2c99169fae 100644
--- a/boards/sim/sim/sim/configs/nxwm/defconfig
+++ b/boards/sim/sim/sim/configs/nxwm/defconfig
@@ -24,6 +24,7 @@ CONFIG_FS_ROMFS=y
 CONFIG_HAVE_CXX=y
 CONFIG_IDLETHREAD_STACKSIZE=8192
 CONFIG_INIT_ENTRYPOINT="nxwm_main"
+CONFIG_LIBC_MAX_EXITFUNS=1
 CONFIG_MQ_MAXMSGSIZE=64
 CONFIG_NSH_FATDEVNO=2
 CONFIG_NSH_LIBRARY=y
@@ -46,7 +47,6 @@ CONFIG_NX_BLOCKING=y
 CONFIG_NX_KBD=y
 CONFIG_SCHED_HPWORK=y
 CONFIG_SCHED_HPWORKPRIORITY=192
-CONFIG_SCHED_ONEXIT=y
 CONFIG_SCHED_WAITPID=y
 CONFIG_SIM_FBBPP=32
 CONFIG_SIM_X11FB=y
diff --git a/boards/sim/sim/sim/configs/posix_spawn/defconfig b/boards/sim/sim/sim/configs/posix_spawn/defconfig
index 2a6c1be9d9..71022fba7d 100644
--- a/boards/sim/sim/sim/configs/posix_spawn/defconfig
+++ b/boards/sim/sim/sim/configs/posix_spawn/defconfig
@@ -38,6 +38,7 @@ CONFIG_IDLETHREAD_STACKSIZE=4096
 CONFIG_INIT_ENTRYPOINT="nsh_main"
 CONFIG_LIBC_ENVPATH=y
 CONFIG_LIBC_EXECFUNCS=y
+CONFIG_LIBC_MAX_EXITFUNS=1
 CONFIG_LIBC_STRERROR=y
 CONFIG_NSH_ARCHINIT=y
 CONFIG_NSH_BUILTIN_APPS=y
@@ -49,7 +50,6 @@ CONFIG_PATH_INITIAL="/mnt/romfs"
 CONFIG_POSIX_SPAWN_PROXY_STACKSIZE=2048
 CONFIG_READLINE_TABCOMPLETION=y
 CONFIG_SCHED_HAVE_PARENT=y
-CONFIG_SCHED_ONEXIT=y
 CONFIG_SCHED_WAITPID=y
 CONFIG_SIM_M32=y
 CONFIG_START_MONTH=6
diff --git a/boards/sim/sim/sim/configs/rc/defconfig b/boards/sim/sim/sim/configs/rc/defconfig
index 76989dffc1..d8dc439428 100644
--- a/boards/sim/sim/sim/configs/rc/defconfig
+++ b/boards/sim/sim/sim/configs/rc/defconfig
@@ -29,6 +29,7 @@ CONFIG_INIT_ENTRYPOINT="nsh_main"
 CONFIG_LIBC_ENVPATH=y
 CONFIG_LIBC_EXECFUNCS=y
 CONFIG_LIBC_FLOATINGPOINT=y
+CONFIG_LIBC_MAX_EXITFUNS=1
 CONFIG_NSH_ARCHINIT=y
 CONFIG_NSH_BUILTIN_APPS=y
 CONFIG_NSH_FILE_APPS=y
@@ -38,7 +39,6 @@ CONFIG_POSIX_SPAWN_PROXY_STACKSIZE=2048
 CONFIG_RC_DUMMY=y
 CONFIG_READLINE_TABCOMPLETION=y
 CONFIG_SCHED_HAVE_PARENT=y
-CONFIG_SCHED_ONEXIT=y
 CONFIG_SCHED_WAITPID=y
 CONFIG_START_MONTH=6
 CONFIG_START_YEAR=2008
diff --git a/boards/sim/sim/sim/configs/romfs/defconfig b/boards/sim/sim/sim/configs/romfs/defconfig
index ec65c631f9..b04e6831c6 100644
--- a/boards/sim/sim/sim/configs/romfs/defconfig
+++ b/boards/sim/sim/sim/configs/romfs/defconfig
@@ -33,6 +33,7 @@ CONFIG_IDLETHREAD_STACKSIZE=4096
 CONFIG_INIT_ENTRYPOINT="nsh_main"
 CONFIG_LIBC_ENVPATH=y
 CONFIG_LIBC_EXECFUNCS=y
+CONFIG_LIBC_MAX_EXITFUNS=1
 CONFIG_LIBC_STRERROR=y
 CONFIG_NSH_ARCHINIT=y
 CONFIG_NSH_ARCHROMFS=y
@@ -49,7 +50,6 @@ CONFIG_PATH_INITIAL="/bin"
 CONFIG_POSIX_SPAWN_PROXY_STACKSIZE=2048
 CONFIG_READLINE_TABCOMPLETION=y
 CONFIG_SCHED_HAVE_PARENT=y
-CONFIG_SCHED_ONEXIT=y
 CONFIG_SCHED_WAITPID=y
 CONFIG_START_MONTH=6
 CONFIG_START_YEAR=2008
diff --git a/boards/sim/sim/sim/configs/rust/defconfig b/boards/sim/sim/sim/configs/rust/defconfig
index e37893556d..af1607e876 100644
--- a/boards/sim/sim/sim/configs/rust/defconfig
+++ b/boards/sim/sim/sim/configs/rust/defconfig
@@ -41,6 +41,7 @@ CONFIG_LIBC_EXECFUNCS=y
 CONFIG_LIBC_LOCALE=y
 CONFIG_LIBC_LOCALE_CATALOG=y
 CONFIG_LIBC_LOCALE_GETTEXT=y
+CONFIG_LIBC_MAX_EXITFUNS=1
 CONFIG_NSH_ARCHINIT=y
 CONFIG_NSH_ARCHROMFS=y
 CONFIG_NSH_BUILTIN_APPS=y
@@ -59,7 +60,6 @@ CONFIG_PSEUDOFS_SOFTLINKS=y
 CONFIG_READLINE_TABCOMPLETION=y
 CONFIG_SCHED_HAVE_PARENT=y
 CONFIG_SCHED_HPWORK=y
-CONFIG_SCHED_ONEXIT=y
 CONFIG_SCHED_WAITPID=y
 CONFIG_START_MONTH=6
 CONFIG_START_YEAR=2008
diff --git a/boards/sim/sim/sim/configs/segger/defconfig b/boards/sim/sim/sim/configs/segger/defconfig
index a6fc389918..46d496ac8b 100644
--- a/boards/sim/sim/sim/configs/segger/defconfig
+++ b/boards/sim/sim/sim/configs/segger/defconfig
@@ -42,6 +42,7 @@ CONFIG_LIBC_EXECFUNCS=y
 CONFIG_LIBC_LOCALE=y
 CONFIG_LIBC_LOCALE_CATALOG=y
 CONFIG_LIBC_LOCALE_GETTEXT=y
+CONFIG_LIBC_MAX_EXITFUNS=1
 CONFIG_NSH_ARCHINIT=y
 CONFIG_NSH_ARCHROMFS=y
 CONFIG_NSH_BUILTIN_APPS=y
@@ -63,7 +64,6 @@ CONFIG_SCHED_HPWORK=y
 CONFIG_SCHED_INSTRUMENTATION=y
 CONFIG_SCHED_INSTRUMENTATION_FILTER=y
 CONFIG_SCHED_INSTRUMENTATION_SYSCALL=y
-CONFIG_SCHED_ONEXIT=y
 CONFIG_SCHED_WAITPID=y
 CONFIG_SEGGER_SYSVIEW=y
 CONFIG_START_MONTH=6
diff --git a/boards/sim/sim/sim/configs/sensor/defconfig b/boards/sim/sim/sim/configs/sensor/defconfig
index d0a99c603c..6e722d867f 100644
--- a/boards/sim/sim/sim/configs/sensor/defconfig
+++ b/boards/sim/sim/sim/configs/sensor/defconfig
@@ -29,6 +29,7 @@ CONFIG_INIT_ENTRYPOINT="nsh_main"
 CONFIG_LIBC_ENVPATH=y
 CONFIG_LIBC_EXECFUNCS=y
 CONFIG_LIBC_FLOATINGPOINT=y
+CONFIG_LIBC_MAX_EXITFUNS=1
 CONFIG_NSH_ARCHINIT=y
 CONFIG_NSH_BUILTIN_APPS=y
 CONFIG_NSH_FILE_APPS=y
@@ -37,7 +38,6 @@ CONFIG_PATH_INITIAL="/bin"
 CONFIG_POSIX_SPAWN_PROXY_STACKSIZE=2048
 CONFIG_READLINE_TABCOMPLETION=y
 CONFIG_SCHED_HAVE_PARENT=y
-CONFIG_SCHED_ONEXIT=y
 CONFIG_SCHED_WAITPID=y
 CONFIG_SENSORS=y
 CONFIG_SENSORS_WTGAHRS2=y
diff --git a/boards/sim/sim/sim/configs/smartfs/defconfig b/boards/sim/sim/sim/configs/smartfs/defconfig
index 4ea8b09faa..aa6a3308c4 100644
--- a/boards/sim/sim/sim/configs/smartfs/defconfig
+++ b/boards/sim/sim/sim/configs/smartfs/defconfig
@@ -36,6 +36,7 @@ CONFIG_FS_SMARTFS=y
 CONFIG_IDLETHREAD_STACKSIZE=4096
 CONFIG_INIT_ENTRYPOINT="nsh_main"
 CONFIG_LIBC_EXECFUNCS=y
+CONFIG_LIBC_MAX_EXITFUNS=1
 CONFIG_MTD=y
 CONFIG_MTD_M25P=y
 CONFIG_MTD_N25QXXX=y
@@ -58,7 +59,6 @@ CONFIG_PSEUDOFS_SOFTLINKS=y
 CONFIG_QSPI_FLASH=y
 CONFIG_READLINE_TABCOMPLETION=y
 CONFIG_SCHED_HAVE_PARENT=y
-CONFIG_SCHED_ONEXIT=y
 CONFIG_SCHED_WAITPID=y
 CONFIG_SPI_FLASH=y
 CONFIG_SPI_FLASH_M25P=y
diff --git a/boards/sim/sim/sim/configs/sotest/defconfig b/boards/sim/sim/sim/configs/sotest/defconfig
index c7686f435d..01eaa2d7e0 100644
--- a/boards/sim/sim/sim/configs/sotest/defconfig
+++ b/boards/sim/sim/sim/configs/sotest/defconfig
@@ -29,6 +29,7 @@ CONFIG_INIT_ENTRYPOINT="nsh_main"
 CONFIG_IOB_NOTIFIER=y
 CONFIG_LIBC_DLFCN=y
 CONFIG_LIBC_ENVPATH=y
+CONFIG_LIBC_MAX_EXITFUNS=1
 CONFIG_LIBC_STRERROR=y
 CONFIG_MM_FILL_ALLOCATIONS=y
 CONFIG_NAME_MAX=64
@@ -64,7 +65,6 @@ CONFIG_RTC_ARCH=y
 CONFIG_RTC_DATETIME=y
 CONFIG_RTC_DRIVER=y
 CONFIG_SCHED_HAVE_PARENT=y
-CONFIG_SCHED_ONEXIT=y
 CONFIG_SCHED_WAITPID=y
 CONFIG_SIG_DEFAULT=y
 CONFIG_SIM_NETDEV=y
diff --git a/boards/sim/sim/sim/configs/sotest32/defconfig b/boards/sim/sim/sim/configs/sotest32/defconfig
index ddd3caf936..078ab1334f 100644
--- a/boards/sim/sim/sim/configs/sotest32/defconfig
+++ b/boards/sim/sim/sim/configs/sotest32/defconfig
@@ -29,6 +29,7 @@ CONFIG_INIT_ENTRYPOINT="nsh_main"
 CONFIG_IOB_NOTIFIER=y
 CONFIG_LIBC_DLFCN=y
 CONFIG_LIBC_ENVPATH=y
+CONFIG_LIBC_MAX_EXITFUNS=1
 CONFIG_LIBC_STRERROR=y
 CONFIG_MM_FILL_ALLOCATIONS=y
 CONFIG_NAME_MAX=64
@@ -64,7 +65,6 @@ CONFIG_RTC_ARCH=y
 CONFIG_RTC_DATETIME=y
 CONFIG_RTC_DRIVER=y
 CONFIG_SCHED_HAVE_PARENT=y
-CONFIG_SCHED_ONEXIT=y
 CONFIG_SCHED_WAITPID=y
 CONFIG_SIG_DEFAULT=y
 CONFIG_SIM_M32=y
diff --git a/boards/sim/sim/sim/configs/tcpblaster/defconfig b/boards/sim/sim/sim/configs/tcpblaster/defconfig
index 76d4087164..cc0a1b858e 100644
--- a/boards/sim/sim/sim/configs/tcpblaster/defconfig
+++ b/boards/sim/sim/sim/configs/tcpblaster/defconfig
@@ -39,6 +39,7 @@ CONFIG_IOB_THROTTLE=16
 CONFIG_LIBC_EXECFUNCS=y
 CONFIG_LIBC_LOCALE=y
 CONFIG_LIBC_LOCALTIME=y
+CONFIG_LIBC_MAX_EXITFUNS=1
 CONFIG_LIBM=y
 CONFIG_MM_REGIONS=2
 CONFIG_MQ_MAXMSGSIZE=64
@@ -96,7 +97,6 @@ CONFIG_READLINE_TABCOMPLETION=y
 CONFIG_SCHED_CHILD_STATUS=y
 CONFIG_SCHED_HAVE_PARENT=y
 CONFIG_SCHED_HPWORK=y
-CONFIG_SCHED_ONEXIT=y
 CONFIG_SERIAL_TERMIOS=y
 CONFIG_SIG_DEFAULT=y
 CONFIG_SIG_EVTHREAD=y
diff --git a/boards/sim/sim/sim/configs/tcploop/defconfig b/boards/sim/sim/sim/configs/tcploop/defconfig
index 26d020bae3..736b893e3f 100644
--- a/boards/sim/sim/sim/configs/tcploop/defconfig
+++ b/boards/sim/sim/sim/configs/tcploop/defconfig
@@ -36,6 +36,7 @@ CONFIG_INIT_ENTRYPOINT="nsh_main"
 CONFIG_LIBC_ENVPATH=y
 CONFIG_LIBC_EXECFUNCS=y
 CONFIG_LIBC_HOSTNAME="IP-Forward"
+CONFIG_LIBC_MAX_EXITFUNS=1
 CONFIG_NET=y
 CONFIG_NETDEVICES=y
 CONFIG_NET_IPv6=y
@@ -62,7 +63,6 @@ CONFIG_READLINE_TABCOMPLETION=y
 CONFIG_SCHED_HAVE_PARENT=y
 CONFIG_SCHED_LPWORK=y
 CONFIG_SCHED_LPWORKPRIORITY=140
-CONFIG_SCHED_ONEXIT=y
 CONFIG_SCHED_WAITPID=y
 CONFIG_START_MONTH=6
 CONFIG_START_YEAR=2008
diff --git a/boards/sim/sim/sim/configs/udgram/defconfig b/boards/sim/sim/sim/configs/udgram/defconfig
index 7afd3c29c0..cd45d78a41 100644
--- a/boards/sim/sim/sim/configs/udgram/defconfig
+++ b/boards/sim/sim/sim/configs/udgram/defconfig
@@ -31,6 +31,7 @@ CONFIG_IDLETHREAD_STACKSIZE=8192
 CONFIG_INIT_ENTRYPOINT="nsh_main"
 CONFIG_LIBC_ENVPATH=y
 CONFIG_LIBC_EXECFUNCS=y
+CONFIG_LIBC_MAX_EXITFUNS=1
 CONFIG_NET=y
 CONFIG_NETDEVICES=y
 CONFIG_NET_LOCAL=y
@@ -43,7 +44,6 @@ CONFIG_NSH_ROMFSDEVNO=1
 CONFIG_NSH_ROMFSETC=y
 CONFIG_PATH_INITIAL="/bin"
 CONFIG_SCHED_HAVE_PARENT=y
-CONFIG_SCHED_ONEXIT=y
 CONFIG_SCHED_WAITPID=y
 CONFIG_START_MONTH=6
 CONFIG_START_YEAR=2008
diff --git a/boards/sim/sim/sim/configs/unionfs/defconfig b/boards/sim/sim/sim/configs/unionfs/defconfig
index 592fc1723f..729530f58f 100644
--- a/boards/sim/sim/sim/configs/unionfs/defconfig
+++ b/boards/sim/sim/sim/configs/unionfs/defconfig
@@ -28,6 +28,7 @@ CONFIG_IDLETHREAD_STACKSIZE=4096
 CONFIG_INIT_ENTRYPOINT="nsh_main"
 CONFIG_LIBC_ENVPATH=y
 CONFIG_LIBC_EXECFUNCS=y
+CONFIG_LIBC_MAX_EXITFUNS=1
 CONFIG_LIBC_STRERROR=y
 CONFIG_NSH_ARCHINIT=y
 CONFIG_NSH_BUILTIN_APPS=y
@@ -38,7 +39,6 @@ CONFIG_NSH_ROMFSDEVNO=1
 CONFIG_NSH_ROMFSETC=y
 CONFIG_PATH_INITIAL="/bin"
 CONFIG_SCHED_HAVE_PARENT=y
-CONFIG_SCHED_ONEXIT=y
 CONFIG_SCHED_WAITPID=y
 CONFIG_START_MONTH=6
 CONFIG_START_YEAR=2008
diff --git a/boards/sim/sim/sim/configs/userfs/defconfig b/boards/sim/sim/sim/configs/userfs/defconfig
index 73eb08d230..e95c588b43 100644
--- a/boards/sim/sim/sim/configs/userfs/defconfig
+++ b/boards/sim/sim/sim/configs/userfs/defconfig
@@ -33,6 +33,7 @@ CONFIG_IDLETHREAD_STACKSIZE=4096
 CONFIG_INIT_ENTRYPOINT="nsh_main"
 CONFIG_LIBC_ENVPATH=y
 CONFIG_LIBC_EXECFUNCS=y
+CONFIG_LIBC_MAX_EXITFUNS=1
 CONFIG_NET=y
 CONFIG_NETDEVICES=y
 CONFIG_NET_LOCAL=y
@@ -51,7 +52,6 @@ CONFIG_POSIX_SPAWN_PROXY_STACKSIZE=2048
 CONFIG_READLINE_TABCOMPLETION=y
 CONFIG_SCHED_HAVE_PARENT=y
 CONFIG_SCHED_LPWORK=y
-CONFIG_SCHED_ONEXIT=y
 CONFIG_SCHED_WAITPID=y
 CONFIG_START_MONTH=6
 CONFIG_START_YEAR=2008
diff --git a/boards/sim/sim/sim/configs/ustream/defconfig b/boards/sim/sim/sim/configs/ustream/defconfig
index d500a73d2d..215a5e966e 100644
--- a/boards/sim/sim/sim/configs/ustream/defconfig
+++ b/boards/sim/sim/sim/configs/ustream/defconfig
@@ -31,6 +31,7 @@ CONFIG_IDLETHREAD_STACKSIZE=4096
 CONFIG_INIT_ENTRYPOINT="nsh_main"
 CONFIG_LIBC_ENVPATH=y
 CONFIG_LIBC_EXECFUNCS=y
+CONFIG_LIBC_MAX_EXITFUNS=1
 CONFIG_NET=y
 CONFIG_NETDEVICES=y
 CONFIG_NET_LOCAL=y
@@ -43,7 +44,6 @@ CONFIG_NSH_ROMFSDEVNO=1
 CONFIG_NSH_ROMFSETC=y
 CONFIG_PATH_INITIAL="/bin"
 CONFIG_SCHED_HAVE_PARENT=y
-CONFIG_SCHED_ONEXIT=y
 CONFIG_SCHED_WAITPID=y
 CONFIG_START_MONTH=6
 CONFIG_START_YEAR=2008
diff --git a/boards/sim/sim/sim/configs/vpnkit/defconfig b/boards/sim/sim/sim/configs/vpnkit/defconfig
index e3bdca40d6..68cb898a07 100644
--- a/boards/sim/sim/sim/configs/vpnkit/defconfig
+++ b/boards/sim/sim/sim/configs/vpnkit/defconfig
@@ -41,6 +41,7 @@ CONFIG_INIT_ENTRYPOINT="nsh_main"
 CONFIG_IOB_NOTIFIER=y
 CONFIG_LIBC_ENVPATH=y
 CONFIG_LIBC_EXECFUNCS=y
+CONFIG_LIBC_MAX_EXITFUNS=1
 CONFIG_MM_FILL_ALLOCATIONS=y
 CONFIG_NET=y
 CONFIG_NETDB_DNSCLIENT=y
@@ -79,7 +80,6 @@ CONFIG_RTC_ARCH=y
 CONFIG_RTC_DATETIME=y
 CONFIG_RTC_DRIVER=y
 CONFIG_SCHED_HAVE_PARENT=y
-CONFIG_SCHED_ONEXIT=y
 CONFIG_SCHED_WAITPID=y
 CONFIG_SIM_HOSTFS=y
 CONFIG_SIM_NETDEV=y
diff --git a/boards/xtensa/esp32/esp32-devkitc/configs/cxx/defconfig b/boards/xtensa/esp32/esp32-devkitc/configs/cxx/defconfig
index f4718c7fea..820f2ca495 100644
--- a/boards/xtensa/esp32/esp32-devkitc/configs/cxx/defconfig
+++ b/boards/xtensa/esp32/esp32-devkitc/configs/cxx/defconfig
@@ -28,6 +28,7 @@ CONFIG_INIT_ENTRYPOINT="nsh_main"
 CONFIG_INTELHEX_BINARY=y
 CONFIG_LIBCXX=y
 CONFIG_LIBCXXABI=y
+CONFIG_LIBC_MAX_EXITFUNS=1
 CONFIG_LIBM=y
 CONFIG_MM_REGIONS=3
 CONFIG_NSH_ARCHINIT=y
@@ -40,7 +41,6 @@ CONFIG_RAM_SIZE=114688
 CONFIG_RAM_START=0x20000000
 CONFIG_RAW_BINARY=y
 CONFIG_RR_INTERVAL=200
-CONFIG_SCHED_ATEXIT=y
 CONFIG_SCHED_WAITPID=y
 CONFIG_START_DAY=6
 CONFIG_START_MONTH=12
diff --git a/boards/xtensa/esp32s2/esp32s2-saola-1/configs/cxx/defconfig b/boards/xtensa/esp32s2/esp32s2-saola-1/configs/cxx/defconfig
index d3987bd9df..1d7b46b8c2 100644
--- a/boards/xtensa/esp32s2/esp32s2-saola-1/configs/cxx/defconfig
+++ b/boards/xtensa/esp32s2/esp32s2-saola-1/configs/cxx/defconfig
@@ -28,6 +28,7 @@ CONFIG_INIT_ENTRYPOINT="nsh_main"
 CONFIG_INTELHEX_BINARY=y
 CONFIG_LIBCXX=y
 CONFIG_LIBCXXABI=y
+CONFIG_LIBC_MAX_EXITFUNS=1
 CONFIG_LIBM=y
 CONFIG_NSH_ARCHINIT=y
 CONFIG_NSH_BUILTIN_APPS=y
@@ -39,7 +40,6 @@ CONFIG_RAM_SIZE=114688
 CONFIG_RAM_START=0x20000000
 CONFIG_RAW_BINARY=y
 CONFIG_RR_INTERVAL=200
-CONFIG_SCHED_ATEXIT=y
 CONFIG_SCHED_WAITPID=y
 CONFIG_START_DAY=6
 CONFIG_START_MONTH=12
diff --git a/boards/xtensa/esp32s3/esp32s3-devkit/configs/cxx/defconfig b/boards/xtensa/esp32s3/esp32s3-devkit/configs/cxx/defconfig
index 92d6386b4e..e7c955c57c 100644
--- a/boards/xtensa/esp32s3/esp32s3-devkit/configs/cxx/defconfig
+++ b/boards/xtensa/esp32s3/esp32s3-devkit/configs/cxx/defconfig
@@ -30,6 +30,7 @@ CONFIG_INIT_ENTRYPOINT="nsh_main"
 CONFIG_INTELHEX_BINARY=y
 CONFIG_LIBCXX=y
 CONFIG_LIBCXXABI=y
+CONFIG_LIBC_MAX_EXITFUNS=1
 CONFIG_LIBM=y
 CONFIG_NSH_ARCHINIT=y
 CONFIG_NSH_BUILTIN_APPS=y
@@ -41,7 +42,6 @@ CONFIG_RAM_SIZE=114688
 CONFIG_RAM_START=0x20000000
 CONFIG_RAW_BINARY=y
 CONFIG_RR_INTERVAL=200
-CONFIG_SCHED_ATEXIT=y
 CONFIG_SCHED_WAITPID=y
 CONFIG_START_DAY=6
 CONFIG_START_MONTH=12