Skip to content

Commit 00718bb

Browse files
committed
unix/main.c: Integrate atexit to be run while exiting.
Signed-off-by: Andrew Leech <andrew@alelec.net>
1 parent e3cba2d commit 00718bb

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/mperrno.h"
4950
#include "py/mphal.h"
5051
#include "py/mpthread.h"
@@ -756,6 +757,11 @@ MP_NOINLINE int main_(int argc, char **argv) {
756757
}
757758
}
758759

760+
#if MICROPY_PY_ATEXIT
761+
int atexit_code = mp_atexit_execute();
762+
ret = (atexit_code != 0) ? atexit_code : ret;
763+
#endif
764+
759765
#if MICROPY_PY_SYS_SETTRACE
760766
MP_STATE_THREAD(prof_trace_callback) = MP_OBJ_NULL;
761767
#endif

0 commit comments

Comments
 (0)