Skip to content

Commit

Permalink
libc: Implement nxtask_exit_cleanup
Browse files Browse the repository at this point in the history
This runs the I/O and FILE cleanup procedures
  • Loading branch information
pussuw committed May 4, 2022
1 parent 46e8964 commit bec0dea
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
9 changes: 9 additions & 0 deletions libs/libc/stdlib/lib_exit.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,18 @@
****************************************************************************/

#include <nuttx/config.h>

#include <stdlib.h>
#include <unistd.h>

#include "atexit.h"

/****************************************************************************
* Public Function Prototypes
****************************************************************************/

void nxtask_exit_cleanup(int status);

/****************************************************************************
* Public Functions
****************************************************************************/
Expand All @@ -38,5 +45,7 @@ void exit(int status)

/* REVISIT: Need to flush files and streams */

nxtask_exit_cleanup(status);

_exit(status);
}
20 changes: 7 additions & 13 deletions sched/task/exit.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,24 +53,24 @@

void _exit(int status)
{
up_exit(status);
up_exit(status & 0xff);
}

/****************************************************************************
* Name: exit
* Name: nxtask_exit_cleanup
*
* Description:
* The exit() function causes normal process termination and the value of
* status & 0377 to be returned to the parent.
* Perform cleanup before task is closed.
*
* All functions registered with atexit() and on_exit() are called, in the
* reverse order of their registration.
* If SCHED_ATEXIT or SCHED_ONEXIT are defined, all functions registered
* with atexit() and on_exit() are called, in the reverse order of their
* registration.
*
* All open streams are flushed and closed.
*
****************************************************************************/

void exit(int status)
void nxtask_exit_cleanup(int status)
{
FAR struct tcb_s *tcb = this_task();

Expand Down Expand Up @@ -101,10 +101,4 @@ void exit(int status)
*/

nxtask_exithook(tcb, status, false);

/* Then "really" exit. Only the lower 8 bits of the exit status are
* used.
*/

_exit(status);
}

0 comments on commit bec0dea

Please sign in to comment.