+static PerlInterpreter* win32_process_perl = NULL;
+
+BOOL WINAPI
+win32_ctrlhandler(DWORD dwCtrlType)
+{
+ dTHX;
+ if (!my_perl) {
+ my_perl = win32_process_perl;
+ if (!my_perl) {
+ return FALSE;
+ }
+ PERL_SET_THX(my_perl);
+ }
+
+ switch(dwCtrlType) {
+ case CTRL_CLOSE_EVENT:
+ /* A signal that the system sends to all processes attached to a console when
+ the user closes the console (either by choosing the Close command from the
+ console window's System menu, or by choosing the End Task command from the
+ Task List
+ */
+ CALL_FPTR(PL_sighandlerp)(1); /* SIGHUP */
+ return TRUE;
+
+ case CTRL_C_EVENT:
+ /* A CTRL+c signal was received */
+ CALL_FPTR(PL_sighandlerp)(2); /* SIGINT */
+ return TRUE;
+
+ case CTRL_BREAK_EVENT:
+ /* A CTRL+BREAK signal was received */
+ CALL_FPTR(PL_sighandlerp)(3); /* SIGQUIT */
+ return TRUE;
+
+ case CTRL_LOGOFF_EVENT:
+ /* A signal that the system sends to all console processes when a user is logging
+ off. This signal does not indicate which user is logging off, so no
+ assumptions can be made.
+ */
+ break;
+ case CTRL_SHUTDOWN_EVENT:
+ /* A signal that the system sends to all console processes when the system is
+ shutting down.
+ */
+ break;
+ default:
+ break;
+ }
+ return FALSE;
+}
+
+
+