def start(self):
        """Register handling of the console control events."""
        if self.is_set:
            self.bus.log('Handler for console events already set.', level=20)
            return

        result = win32api.SetConsoleCtrlHandler(self.handle, 1)
        if result == 0:
            self.bus.log(
                'Could not SetConsoleCtrlHandler (error %r)'
                % win32api.GetLastError(),
                level=40,
            )
        else:
            self.bus.log('Set handler for console events.', level=20)
            self.is_set = True
Register handling of the console control events.
cherrypy/process/win32.py