Allow sending SIGINT to child processes on Windows *if* they are running Perl
authorJan Dubois <jand@activestate.com>
Mon, 16 Apr 2007 17:52:25 +0000 (10:52 -0700)
committerSteve Hay <SteveHay@planit.com>
Thu, 19 Apr 2007 12:15:30 +0000 (12:15 +0000)
From: "Jan Dubois" <jand@activestate.com>
Message-ID: <01e301c7808a$ac0cca30$04265e90$@com>

p4raw-id: //depot/perl@30979

win32/win32.c

index 55239e5..c69c2a7 100644 (file)
@@ -4910,6 +4910,16 @@ Perl_sys_intern_init(pTHX)
        /* Force C runtime signal stuff to set its console handler */
        signal(SIGINT,win32_csighandler);
        signal(SIGBREAK,win32_csighandler);
+
+        /* We spawn asynchronous processes with the CREATE_NEW_PROCESS_GROUP
+         * flag.  This has the side-effect of disabling Ctrl-C events in all
+         * processes in this group.  At least on Windows NT and later we
+         * can re-enable Ctrl-C handling by calling SetConsoleCtrlHandler()
+         * with a NULL handler.  This is not valid on Windows 9X.
+         */
+        if (IsWinNT())
+            SetConsoleCtrlHandler(NULL,FALSE);
+
        /* Push our handler on top */
        SetConsoleCtrlHandler(win32_ctrlhandler,TRUE);
     }