nuttx/sched
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
..
addrenv sched/addrenv: Remove up_addrenv_restore 2023-02-08 02:51:23 +08:00
clock clock: adjust clock function to support tick 2022-11-01 21:54:20 +08:00
environ sched/env: Don't need copy env variable from parent in env_dup 2022-10-19 08:22:56 +09:00
group group/group_addrenv: Move address environment from group -> tcb 2023-02-08 02:51:23 +08:00
init Launch the initial task through task_spawn instead of nxtask_create 2023-01-25 23:34:52 +02:00
irq sched/irq: add spin_unlock_irqsave/irqrestore_wo_note 2023-01-02 22:29:01 +08:00
misc sched/addrenv: Remove up_addrenv_restore 2023-02-08 02:51:23 +08:00
module nuttx: Use MIN/MAX definitions from "sys/param.h" 2023-02-01 23:47:44 +08:00
mqueue sched/getpid: replace syscall getpid/tid/ppid() to kernel version 2023-02-02 10:33:01 +08:00
paging nuttx/sched: merge up_block_task and up_unblock_task 2022-11-22 22:59:08 +08:00
pthread sched/addrenv: Fix system crash when process group has been deleted 2023-02-08 02:51:23 +08:00
sched sched/addrenv: Fix system crash when process group has been deleted 2023-02-08 02:51:23 +08:00
semaphore sched/getpid: replace syscall getpid/tid/ppid() to kernel version 2023-02-02 10:33:01 +08:00
signal sched: Implement tkill/tgkill 2023-01-26 08:11:56 +02:00
task sched/nxtask_sigchild: Set process exit code to group exit code 2023-02-10 00:36:30 +08:00
timer sched/getpid: replace syscall getpid/tid/ppid() to kernel version 2023-02-02 10:33:01 +08:00
tls sched/group: fix task info heap-use-after-free 2023-01-11 01:53:59 +08:00
wdog nuttx: Use MIN/MAX definitions from "sys/param.h" 2023-02-01 23:47:44 +08:00
wqueue sched/wqueue: semaphore count should be consistent with the number of work entries. 2023-01-28 21:45:10 +09:00
Kconfig sched/signal: Fix typo error in Kconfig(SIG_SEGA->SIG_SEGV) 2023-01-28 09:07:23 +02:00
Makefile group/group_addrenv: Move address environment from group -> tcb 2023-02-08 02:51:23 +08:00