Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 4e59793eb8befe610cee7238f6e9dc1583ba64af
Ticket: e66e44444023ee253956979c54c905c6006f4540
Change Ctrl-C handling in Windows console
User & Date: apnadkarni on 2015-03-19 02:33:21
Changes

  1. assignee changed to: "nobody"
  2. closer changed to: "nobody"
  3. cmimetype changed to: "text/plain"
  4. comment changed to:
    Background: Windows allows Ctrl-C, Ctrl-Break etc. to be trapped by the application via the SetConsoleCtrlHandler call. Although Tcl itself does not support this in the core, extensions such as twapi do. However, a feature/bug/quirk in the tclWinConsole.c:ReadConsoleBytes function makes this trapping ineffective. As documented in MSDN, a Ctrl-C results in the Windows ReadConsole call returning successfully but with 0 bytes read. This gets funneled up the Tcl channel system as EOF on stdin and consequently the REPL loop exits.
    
    The proposed change would be to change ReadConsoleBytes to detect this (GetLastError() returns ERROR_OPERATION_ABORTED) and simply repost the ReadConsole.
    
    There will be no observed change in the default behaviour because the default OS handler (run in a separate thread) will still exit the process on a Ctrl-C. However, applications that use extensions to trap Ctrl-C by replacing the default handler will work as expected.
    
    The proposed change is in the Windows-specific code and will not affect other platforms.
    
    Reference: http://stackoverflow.com/questions/27903208/tcl-and-ctrl-c-in-windows-console/27904696#27904696
    
  5. is_private changed to: "0"
  6. login: "apnadkarni"
  7. priority changed to: "5 Medium"
  8. resolution changed to: "None"
  9. severity changed to: "Minor"
  10. status changed to: "Open"
  11. submitter changed to: "apnadkarni"
  12. subsystem changed to: "25. Channel System"
  13. title changed to: "Change Ctrl-C handling in Windows console"
  14. type changed to: "RFE"