[3.9] bpo-41602: raise SIGINT exit code on KeyboardInterrupt from pymain_run_module (GH-21956) (#22397)

Closes bpo issue 41602.
(cherry picked from commit a68a2ad19c891faa891904b3da537911cc77df21)

Co-authored-by: Thomas Grainger <tagrain@gmail.com>
diff --git a/Modules/main.c b/Modules/main.c
index 4a76f44..2cc891f 100644
--- a/Modules/main.c
+++ b/Modules/main.c
@@ -287,7 +287,11 @@
         Py_DECREF(module);
         return pymain_exit_err_print();
     }
+    _Py_UnhandledKeyboardInterrupt = 0;
     result = PyObject_Call(runmodule, runargs, NULL);
+    if (!result && PyErr_Occurred() == PyExc_KeyboardInterrupt) {
+        _Py_UnhandledKeyboardInterrupt = 1;
+    }
     Py_DECREF(runpy);
     Py_DECREF(runmodule);
     Py_DECREF(module);