diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp
index 4c8dcc20ea0..25a67af3425 100644
--- a/core/bind/core_bind.cpp
+++ b/core/bind/core_bind.cpp
@@ -686,6 +686,10 @@ int _OS::get_exit_code() const {
void _OS::set_exit_code(int p_code) {
+ if (p_code < 0 || p_code > 125) {
+ WARN_PRINT("For portability reasons, the exit code should be set between 0 and 125 (inclusive).");
+ }
+
OS::get_singleton()->set_exit_code(p_code);
}
diff --git a/doc/classes/OS.xml b/doc/classes/OS.xml
index 54b4f3df64c..265e87eba37 100644
--- a/doc/classes/OS.xml
+++ b/doc/classes/OS.xml
@@ -905,7 +905,7 @@
The current screen index (starting from 0).
- The exit code passed to the OS when the main loop exits.
+ The exit code passed to the OS when the main loop exits. By convention, an exit code of [code]0[/code] indicates success whereas a non-zero exit code indicates an error. For portability reasons, the exit code should be set between 0 and 125 (inclusive).
If [code]true[/code], the engine tries to keep the screen on while the game is running. Useful on mobile.