summaryrefslogtreecommitdiffstatshomepage
path: root/shared/runtime/pyexec.h
diff options
context:
space:
mode:
authorDavid Grayson <davidegrayson@gmail.com>2023-04-04 12:05:45 -0700
committerDamien George <damien@micropython.org>2023-04-05 10:38:50 +1000
commitc046b23ea29e0183c899a8dbe1da3bed3440a255 (patch)
tree67b39a4bfff94fe103115f3f0c589fce82363a33 /shared/runtime/pyexec.h
parentdb4b416ea824e66414530b84928671f701ac5b84 (diff)
downloadmicropython-c046b23ea29e0183c899a8dbe1da3bed3440a255.tar.gz
micropython-c046b23ea29e0183c899a8dbe1da3bed3440a255.zip
shared/runtime/pyexec: Don't allow Ctrl+C to interrupt frozen boot code.
Helps prevent the filesystem from getting formatted by mistake, among other things. For example, on a Pico board, entering Ctrl+D and Ctrl+C fast many times will eventually wipe the filesystem (without warning or notice). Further rationale: Ctrl+C is used a lot by automation scripts (eg mpremote) and UI's (eg Mu, Thonny) to get the board into a known state. If the board is not responding for a short time then it's not possible to know if it's just a slow start up (eg in _boot.py), or an infinite loop in the main application. The former should not be interrupted, but the latter should. The only way to distinguish these two cases would be to wait "long enough", and if there's nothing on the serial after "long enough" then assume it's running the application and Ctrl+C should break out of it. But defining "long enough" is impossible for all the different boards and their possible behaviour. The solution in this commit is to make it so that frozen start-up code cannot be interrupted by Ctrl+C. That code then effectively acts like normal C start-up code, which also cannot be interrupted. Note: on the stm32 port this was never seen as an issue because all start-up code is in C. But now other ports start to put more things in _boot.py and so this problem crops up. Signed-off-by: David Grayson <davidegrayson@gmail.com>
Diffstat (limited to 'shared/runtime/pyexec.h')
-rw-r--r--shared/runtime/pyexec.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/shared/runtime/pyexec.h b/shared/runtime/pyexec.h
index 981e7dca9f..64c5ef9434 100644
--- a/shared/runtime/pyexec.h
+++ b/shared/runtime/pyexec.h
@@ -46,7 +46,7 @@ int pyexec_raw_repl(void);
int pyexec_friendly_repl(void);
int pyexec_file(const char *filename);
int pyexec_file_if_exists(const char *filename);
-int pyexec_frozen_module(const char *name);
+int pyexec_frozen_module(const char *name, bool allow_keyboard_interrupt);
void pyexec_event_repl_init(void);
int pyexec_event_repl_process_char(int c);
extern uint8_t pyexec_repl_active;