Skip to content

Commit 741e1d9

Browse files
authored
Merge pull request #3043 from DavePutz/Issue-2865
Issue #2865 -Clean up after ctrl-c interrupt in sleep
2 parents f67b307 + b80abf1 commit 741e1d9

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

supervisor/shared/tick.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,15 @@ void mp_hal_delay_ms(mp_uint_t delay) {
102102
while (remaining > 0) {
103103
RUN_BACKGROUND_TASKS;
104104
// Check to see if we've been CTRL-Ced by autoreload or the user.
105-
if(MP_STATE_VM(mp_pending_exception) == MP_OBJ_FROM_PTR(&MP_STATE_VM(mp_kbd_exception)) ||
106-
MP_STATE_VM(mp_pending_exception) == MP_OBJ_FROM_PTR(&MP_STATE_VM(mp_reload_exception)) ||
105+
if(MP_STATE_VM(mp_pending_exception) == MP_OBJ_FROM_PTR(&MP_STATE_VM(mp_kbd_exception)))
106+
{
107+
// clear exception and generate stacktrace
108+
MP_STATE_VM(mp_pending_exception) = MP_OBJ_NULL;
109+
nlr_raise(&MP_STATE_VM(mp_kbd_exception));
110+
}
111+
if( MP_STATE_VM(mp_pending_exception) == MP_OBJ_FROM_PTR(&MP_STATE_VM(mp_reload_exception)) ||
107112
WATCHDOG_EXCEPTION_CHECK()) {
113+
// stop sleeping immediately
108114
break;
109115
}
110116
remaining = end_tick - port_get_raw_ticks(NULL);

0 commit comments

Comments
 (0)