Skip to content

signal.SIGABRT equals 22 on Windows #15540

@jonathandung

Description

@jonathandung

In signal.h for many windows distributions, macro definitions along the line of the following are seen.

#define SIGINT 2 /* Interactive attention */
#define SIGILL	4 /* Illegal instruction */
#define SIGFPE 8 /* Floating point error */
#define SIGSEGV 11 /* Segmentation violation */
#define SIGTERM 15 /* Termination request */
#define SIGBREAK 21 /* Control-break */
#define SIGABRT 22 /* Abnormal termination (abort) */

Verification:

> python
Python 3.14.0 (tags/v3.14.0:ebf955d, Oct  7 2025, 10:15:03) [MSC v.1944 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> for sig in __import__('signal').valid_signals(): print(f'{sig.name}: {sig.value}')
SIGINT: 2
SIGILL: 4
SIGFPE: 8
SIGSEGV: 11
SIGTERM: 15
SIGBREAK: 21
SIGABRT: 22

Note the discrepancy: Windows has much less signals (which typeshed takes into account using conditional annotations), but on other systems, the value of SIGABRT is 6, and 22 is allocated to SIGTTOU.

Herein lies the issue. In the signal stub:

class Signals(IntEnum):
    SIGABRT = 6 # HERE
    SIGFPE = 8

There is no conditional handling for windows, unlike below:

    if sys.platform == "win32": # HERE
        SIGBREAK = 21
        CTRL_C_EVENT = 0
        CTRL_BREAK_EVENT = 1
    else:
        SIGALRM = 14
        SIGBUS = 7

This is easily fixable. I will open a PR to fix it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions