python / python/cpython

Embedded use vs. signal handlers

Open
#93,411 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

3.13 stdlib type-feature
Dominant language
Python
Stars
77.2k
Forks
36k
PR merge metrics
PR metrics pending

Description

Enhancement

C signal handlers should be restore-able. Ideally you also want to call them from Python.

signal.signal(signal.SIGINT, signal.getsignal(signal.SIGINT))

This (ostensibly no-op) code raises TypeError when you use it in an embedded Python interpreter and a signal handler has been installed by the C (or whatever) side.

It shouldn't. My Python code wants to be able to restore the signal handler to its previous state when it's done.

Ideally my code should also be able to wrap that C handler, i.e. the result of getsignal() should be a callable from Python.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No source file or test is named. Start by examining the signal.signal and signal.getsignal behavior described for an embedded Python interpreter, including handlers installed by C; done should allow restoring that prior handler and, if feasible, expose it as a callable that Python can wrap.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, python
Domain
operating-systems
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.