Skip to content

Commit c11bd0e

Browse files
committed
unix/main.c: Integrate atexit to be run at the start of exit process.
Signed-off-by: Andrew Leech <[email protected]>
1 parent 707d79b commit c11bd0e

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

ports/unix/main.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
#include "py/gc.h"
4646
#include "py/objstr.h"
4747
#include "py/cstack.h"
48+
#include "py/modatexit.h"
4849
#include "py/mphal.h"
4950
#include "py/mpthread.h"
5051
#include "extmod/misc.h"
@@ -748,6 +749,11 @@ MP_NOINLINE int main_(int argc, char **argv) {
748749
}
749750
}
750751

752+
#if MICROPY_PY_ATEXIT
753+
int atexit_code = mp_atexit_execute();
754+
ret = (atexit_code != 0) ? atexit_code : ret;
755+
#endif
756+
751757
#if MICROPY_PY_SYS_SETTRACE
752758
MP_STATE_THREAD(prof_trace_callback) = MP_OBJ_NULL;
753759
#endif

0 commit comments

Comments
 (0)