summaryrefslogtreecommitdiff
path: root/nuttx/sched/task_delete.c
diff options
context:
space:
mode:
Diffstat (limited to 'nuttx/sched/task_delete.c')
-rw-r--r--nuttx/sched/task_delete.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/nuttx/sched/task_delete.c b/nuttx/sched/task_delete.c
index 31715051a..4cd2b3ba7 100644
--- a/nuttx/sched/task_delete.c
+++ b/nuttx/sched/task_delete.c
@@ -140,6 +140,16 @@ int task_delete(pid_t pid)
PANIC(OSERR_BADDELETESTATE);
}
+ /* Perform common task termination logic (flushing streams, calling
+ * functions registered by at_exit/on_exit, etc.). We need to do
+ * this as early as possible so that higher level clean-up logic
+ * can run in a healthy tasking environment.
+ *
+ * I suppose EXIT_SUCCESS is an appropriate return value???
+ */
+
+ task_exithook(dtcb, EXIT_SUCCESS);
+
/* Remove the task from the OS's tasks lists. */
saved_state = irqsave();
@@ -151,13 +161,6 @@ int task_delete(pid_t pid)
sched_unlock();
- /* Perform common task termination logic (flushing streams, calling
- * functions registered by at_exit/on_exit, etc.). I suppose EXIT_SUCCESS
- * is an appropriate return value???
- */
-
- task_exithook(dtcb, EXIT_SUCCESS);
-
/* Deallocate its TCB */
sched_releasetcb(dtcb);