classification
Title: PEP 475: handle EINTR in the signal module
Type: Stage:
Components: Versions: Python 3.5
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: python-dev, vstinner
Priority: normal Keywords: patch

Created on 2015-03-20 01:13 by vstinner, last changed 2015-03-27 13:36 by python-dev. This issue is now closed.

Files
File name Uploaded Description Edit
sigtimedwait_eintr.patch vstinner, 2015-03-20 01:13 review
signal_eintr.patch vstinner, 2015-03-20 09:03 review
Messages (8)
msg238595 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2015-03-20 01:13
Attached patch changes signal.sigtimedwait() to retry if sigtimedwait() failed with EINTR and the signal handler didn't raise an exception.
msg238596 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2015-03-20 01:18
It looks like signal.sigwaitinfo() can also fail with InterruptedError. It should also be modified.
msg238620 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2015-03-20 09:03
signal_eintr.py: More complete patch, modify also signal.sigwaitinfo().

--

I don't think that other signal functions need to be modified to handle EINTR.

POSIX manual pages:
- "The pthread_sigmask() function shall not return an error code of [EINTR]."
- "The pthread_kill() function shall not return an error code of [EINTR]."

pause() fails with EINTR when it receives a signal, but signal.pause() doesn't raise InterruptedError in this case, it only returns None, because we expect a signal.

I tested: signal.sigwait([]) doesn't fail with EINTR with a signal is received. No need to modify this function.

On Linux, signal.set_wakeup_fd() doesn't fail with InterruptedError.
msg238651 - (view) Author: Roundup Robot (python-dev) Date: 2015-03-20 12:02
New changeset 33a6e2587aad by Victor Stinner in branch 'default':
Issue #23715: signal.sigwaitinfo() and signal.sigtimedwait() are now retried
https://hg.python.org/cpython/rev/33a6e2587aad
msg238656 - (view) Author: Roundup Robot (python-dev) Date: 2015-03-20 12:38
New changeset 8f9925a02fe7 by Victor Stinner in branch 'default':
Issue #23715: Enhance test.script_helper to investigate test_eintr failure
https://hg.python.org/cpython/rev/8f9925a02fe7
msg238659 - (view) Author: Roundup Robot (python-dev) Date: 2015-03-20 12:43
New changeset 79aed09a9fa5 by Victor Stinner in branch 'default':
Issue #23715: Fix test_eintr, skip tests on signal.sigwaitinfo() and
https://hg.python.org/cpython/rev/79aed09a9fa5
msg238663 - (view) Author: Roundup Robot (python-dev) Date: 2015-03-20 13:02
New changeset ed8c2a4a6d3d by Victor Stinner in branch 'default':
Issue #23715: Fix test_script_helper
https://hg.python.org/cpython/rev/ed8c2a4a6d3d
msg239403 - (view) Author: Roundup Robot (python-dev) Date: 2015-03-27 13:36
New changeset 35bc15fa4930 by Victor Stinner in branch 'default':
Issue #23715: Fix test_sigtimedwait() of test_eintr
https://hg.python.org/cpython/rev/35bc15fa4930
History
Date User Action Args
2015-03-27 13:36:01python-devsetmessages: + msg239403
2015-03-20 13:02:47python-devsetmessages: + msg238663
2015-03-20 12:43:44python-devsetmessages: + msg238659
2015-03-20 12:38:53python-devsetmessages: + msg238656
2015-03-20 12:10:39vstinnersetstatus: open -> closed
resolution: fixed
2015-03-20 12:02:41python-devsetnosy: + python-dev
messages: + msg238651
2015-03-20 09:03:25vstinnersetfiles: + signal_eintr.patch

messages: + msg238620
2015-03-20 01:19:05vstinnerlinkissue23648 dependencies
2015-03-20 01:18:36vstinnersetmessages: + msg238596
title: PEP 475: signal.sigtimedwait() must retry if sigtimedwait() failed with EINTR -> PEP 475: handle EINTR in the signal module
2015-03-20 01:13:29vstinnercreate