python / cpython

The Python programming language
https://www.python.org
Other
61.91k stars 29.78k forks source link

subprocess.Popen: Confusing documentation for restore_signals #77166

Open 24996bb1-ce60-4f5f-bbcf-94bdd2c53bc7 opened 6 years ago

24996bb1-ce60-4f5f-bbcf-94bdd2c53bc7 commented 6 years ago
BPO 32985
Nosy @gpshead, @giampaolo, @bitdancer

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields: ```python assignee = None closed_at = None created_at = labels = ['library'] title = 'subprocess.Popen: Confusing documentation for restore_signals' updated_at = user = 'https://bugs.python.org/ntrrgc' ``` bugs.python.org fields: ```python activity = actor = 'r.david.murray' assignee = 'none' closed = False closed_date = None closer = None components = ['Library (Lib)'] creation = creator = 'ntrrgc' dependencies = [] files = [] hgrepos = [] issue_num = 32985 keywords = [] message_count = 2.0 messages = ['313146', '313630'] nosy_count = 4.0 nosy_names = ['gregory.p.smith', 'giampaolo.rodola', 'r.david.murray', 'ntrrgc'] pr_nums = [] priority = 'normal' resolution = None stage = None status = 'open' superseder = None type = None url = 'https://bugs.python.org/issue32985' versions = ['Python 3.6'] ```

24996bb1-ce60-4f5f-bbcf-94bdd2c53bc7 commented 6 years ago

The docs state:

If restore_signals is true (the default) all signals that Python has set to SIG_IGN are restored to SIG_DFL in the child process before the exec. Currently this includes the SIGPIPE, SIGXFZ and SIGXFSZ signals. (POSIX only)

The first phrase and the second may seem contradictory for anyone that uses signal handling in their code.

I would definitely not describe the set of "SIGPIPE, SIGXFZ and SIGXFSZ" as "all signals that Python has set". It actually means "all the signals that Python set at startup"; the user could have changed different signals than these (e.g. SIGINT) for various purposes (e.g. not getting a KeyboardInterrupt while an interactive process is running).

The current wording may suggest that all signals changed by the user are reset in the child process, but this is not the case -- I could confirm by looking at _Py_RestoreSignals(). Only these three specific signals are restored.

bitdancer commented 6 years ago

Well, I imagine the original author thought of "python" as python itself, not the user's python program. That's certainly how I understood it when I read it in your message. It would not be a bad thing to clarify that, though.

akulakov commented 1 year ago

The word 'currently' should make it clear that the following does not refer to the signals user may have set in their program, as that would vary and could not be included in the documentation as a static list.