Handle task spawn attributes as task spawn file actions are handled.
Why? This removes the need for sched_lock() when the task is being
spawned. When loading the new task from a file the scheduler can be
locked for a VERY LONG time, in the order of hundreds of milliseconds!
This is unacceptable for real time operation.
Also fixes a latent bug in exec_module, spawn_file_actions is executed
at a bad location; when CONFIG_ARCH_ADDRENV=y actions will point to the
new process's address environment (as it is temporarily instantiated at
that point). Fix this by moving it to after addrenv_restore.
There is a problem when vfork() calls execv() (or execl()) to start a new application:
When the parent thread calls vfork() it receives and gets the pid of the vforked task,
and not the pid of the desired execv'ed application.
see issue #3334
Signed-off-by: yangyalei <yangyalei@xiaomi.com>
Fix the problem when vfork() calls execv() (or execl()) to start a new application:
When the parent thread calls vfork() it receives and gets the pid of the vforked task,
and not the pid of the desired execv'ed application.
issue #3334
Signed-off-by: yangyalei <yangyalei@xiaomi.com>
The spawn proxy thread is a special existence in NuttX, usually some developers
spend a lot of time on stack overflow of spawn proxy thread:
https://github.com/apache/nuttx/issues/9046https://github.com/apache/nuttx/pull/9081
In order to avoid similar issues, this PR will remove spawn proxy thread to simplify
the process of task/posix_spawn().
1. Postpone the related processing of spawn file actions until after task_init()
2. Delete the temporary thread of spawn proxy and related global variables
Signed-off-by: chao an <anchao@xiaomi.com>
If address environments are in use, it is not possible to simply
memcpy from from one process to another. The current implementation
of env_dup does precisely this and thus, it fails at once when it is
attempted between two user processes.
The solution is to use the kernel's heap as an intermediate buffer.
This is a simple, effective and common way to do a fork().
Obviously this is not needed for kernel processes.
* Simplify EINTR/ECANCEL error handling
1. Add semaphore uninterruptible wait function
2 .Replace semaphore wait loop with a single uninterruptible wait
3. Replace all sem_xxx to nxsem_xxx
* Unify the void cast usage
1. Remove void cast for function because many place ignore the returned value witout cast
2. Replace void cast for variable with UNUSED macro
1. Move exepath_*() related code to libc/misc
1. Rename exepath_ to envpath_
2. Rename BINFMT_EXEPATH to LIB_ENVPATH
libs/libc/modlib: Add pre module library symbol table support
binfmt: Refactor binfmt_exec.c
This change also fixes an argv issue for CONFIG_SCHED_ONEXIT=n
or CONFIG_SCHED_HAVE_PARENT=n
Signed-off-by: Masayuki Ishikawa <Masayuki.Ishikawa@jp.sony.com>
Approved-by: GregoryN <gnutt@nuttx.org>
binfmt: Fix some compilation issues introduced in previous changes. Verfied with the STM32F4-Discovery ELF configuration.
binfmt: schedule_unload() is an internal OS function and must not alter the errno variable.
binfmt: unload_module() is an internal OS function and must not alter the errno variable.
binfmt: load_module() is an internal OS function and must not alter the errno variable.
binfmt: exec_module() is an internal OS function and must not alter the errno variable.