Tk Source Code

View Ticket
Login
Ticket UUID: f3e96942ed0123799d269adbcfa39bb1c1895058
Title: macOS: TkpInit replaces the SIGINT, SIGHUP and SIGTERM handlers of the application which embeds Tk
Type: Bug Version: trunk
Submitter: Created on: 2026-09-17 10:08:57
Subsystem: 66. Aqua Window Operations Assigned To:
Priority: Severity: Important
Status: Open Last Modified: 2026-09-17 10:08:57
Resolution: Closed By:
    Closed on:
Description:
Since [d69b5cecd5] (fix for [c2483bfe4b]), `TkpInit()` on macOS installs `TkMacOSXSignalHandler`, which calls `Tcl_Exit(1)`, for SIGINT, SIGHUP and SIGTERM. It does this unconditionally, so it also replaces handlers installed by the application which embeds Tk.

In Python, the SIGINT handler raises `KeyboardInterrupt`. Once a Tk window has been created, Ctrl-C (or SIGINT sent with `pthread_kill()`, which IDLE is going to use to interrupt user code) silently terminates the process with exit status 1 instead. Python-level SIGTERM and SIGHUP handlers stop working as well.

Branch mac-signal-handlers ([87fa518cee]) installs the Tk handler only if the previous disposition is `SIG_DFL`, so `wish` behaves as before.