nuttx/sched/task
Ville Juven 9638187192 sched/nxtask_sigchild: Set process exit code to group exit code
There is an issue where the wrong process exit code is given to the parent
when a process exits. This happens when the process has pthreads running
user code i.e. not within a cancel point / system call.

Why does this happen ?

When exit() is called, the following steps are done:
- group_kill_children(), which tells the children to die via pthread_cancel()

Then, one of two things can happen:
1. if the child is in a cancel point, it gets scheduled to allow it to leave
   the cancel point and gets destroyed immediately
2. if the child is not in a cancel point, a "cancel pending" flag is set and
   the child will die when the next cancel point is encountered

So what is the problem here?

The last thread alive dispatches SIGCHLD to the parent, which carries the
process's exit code. The group head has the only meaningful exit code and
this is what should be passed. However, in the second case, the group head
exits before the child, taking the process exit code to its grave. The child
that was alive will exit next and will pass its "status" to the parent process,
but this status is not the correct value to pass.

This commit fixes the issue by passing the group head's exit code ALWAYS to
the parent process.
2023-02-10 00:36:30 +08:00
..
exit.c libc/stdio: Flush streams in userspace when process exits 2022-12-22 20:16:11 +08:00
Make.defs sched/Makefile: move task_reparent.c to appropriate Makefile 2022-07-27 23:22:37 +08:00
spawn.h Replace nxsem API when used as a lock with nxmutex API 2022-10-17 15:59:46 +09:00
task_activate.c nuttx/sched: merge up_block_task and up_unblock_task 2022-11-22 22:59:08 +08:00
task_cancelpt.c sched/mqueue: make mqueue and mqueue sysv can disable separately 2022-11-16 20:03:40 +08:00
task_create.c sched/spawn: Support task_spawnattr_[set|get]stackaddr 2022-10-31 12:46:58 +09:00
task_delete.c libc/stdio: Flush streams in userspace when process exits 2022-12-22 20:16:11 +08:00
task_execve.c sched/task: Implement execle and execve 2022-04-22 10:40:31 +03:00
task_exit.c libc/stdio: Flush streams in userspace when process exits 2022-12-22 20:16:11 +08:00
task_exithook.c sched/nxtask_sigchild: Set process exit code to group exit code 2023-02-10 00:36:30 +08:00
task_getgroup.c
task_getpid.c sched/task: add kernel interface nxsched_* gettid/getpid/getppid 2023-02-02 10:33:01 +08:00
task_getppid.c sched/task: add kernel interface nxsched_* gettid/getpid/getppid 2023-02-02 10:33:01 +08:00
task_gettid.c sched/task: add kernel interface nxsched_* gettid/getpid/getppid 2023-02-02 10:33:01 +08:00
task_init.c group/group_addrenv: Move address environment from group -> tcb 2023-02-08 02:51:23 +08:00
task_posixspawn.c sched/waitpid: rename nx_waitpid() to nxsched_waitpid() 2023-02-01 20:40:41 +08:00
task_prctl.c prctl: Replace strncpy with strlcpy for safety 2022-08-24 01:54:53 +08:00
task_recover.c sched/mqueue: make mqueue and mqueue sysv can disable separately 2022-11-16 20:03:40 +08:00
task_reparent.c
task_restart.c sched/semaphore: fix priority boost restoration for priority inheritance 2022-10-03 15:14:24 -03:00
task_setcancelstate.c Revert "libc: Call pthread_exit in user-space by up_pthread_exit" 2022-02-09 21:21:43 +08:00
task_setcanceltype.c Revert "libc: Call pthread_exit in user-space by up_pthread_exit" 2022-02-09 21:21:43 +08:00
task_setup.c task_setup: set sigprocmask directly to improve performance 2022-12-17 13:52:15 +08:00
task_spawn.c sched/waitpid: rename nx_waitpid() to nxsched_waitpid() 2023-02-01 20:40:41 +08:00
task_spawnparms.c use SEM_INITIALIZER inside of NXSEM_INITIALIZER 2022-10-22 14:50:48 +08:00
task_start.c libc/tls: Make tls_get_info as the pulibc function instead up_tls_info 2022-06-03 23:56:50 +03:00
task_starthook.c
task_terminate.c sched: fix task_delete crash in SMP case 2023-01-18 14:11:18 +09:00
task_testcancel.c
task_tls_alloc.c Replace nxsem API when used as a lock with nxmutex API 2022-10-17 15:59:46 +09:00
task_vfork.c libc: Move queue.h from include to include/nuttx 2022-09-26 08:04:58 +02:00
task.h libc/stdio: Flush streams in userspace when process exits 2022-12-22 20:16:11 +08:00