| 54 | ****************************************************************************/ |
| 55 | |
| 56 | void _exit(int status) |
| 57 | { |
| 58 | FAR struct tcb_s *tcb = this_task(); |
| 59 | |
| 60 | /* Only the lower 8-bits of status are used */ |
| 61 | |
| 62 | status &= 0xff; |
| 63 | |
| 64 | #ifdef HAVE_GROUP_MEMBERS |
| 65 | /* Kill all of the children of the group, preserving only this thread. |
| 66 | * exit() is normally called from the main thread of the task. pthreads |
| 67 | * exit through a different mechanism. |
| 68 | */ |
| 69 | |
| 70 | if ((tcb->flags & TCB_FLAG_TTYPE_MASK) != TCB_FLAG_TTYPE_KERNEL) |
| 71 | { |
| 72 | group_kill_children(tcb); |
| 73 | } |
| 74 | |
| 75 | #endif |
| 76 | |
| 77 | /* Make sure that we are in a critical section with local interrupts. |
| 78 | * The IRQ state will be restored when the next task is started. |
| 79 | */ |
| 80 | |
| 81 | enter_critical_section(); |
| 82 | |
| 83 | /* Perform common task termination logic. This will get called again later |
| 84 | * through logic kicked off by up_exit(). |
| 85 | * |
| 86 | * REVISIT: Tt should not be necessary to call this here, but releasing the |
| 87 | * task group (especially the group file list) requires that it is done |
| 88 | * here. |
| 89 | * |
| 90 | * The reason? up_exit removes the current process from the ready-to-run |
| 91 | * list and trying to execute code that depends on this_task() crashes at |
| 92 | * once, or does something very naughty. |
| 93 | */ |
| 94 | |
| 95 | tcb->flags |= TCB_FLAG_EXIT_PROCESSING; |
| 96 | |
| 97 | nxtask_exithook(tcb, status); |
| 98 | |
| 99 | up_exit(status); |
| 100 | } |
no test coverage detected