Visitar URL original
Documentation of `signal.pause` is incorrect · Issue #100557 · python/cpython · GitHub
The Wayback Machine - https://web.archive.org/web/20221231112913/https://github.com/python/cpython/issues/100557
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation of signal.pause is incorrect #100557

Open
teythoon opened this issue Dec 27, 2022 · 0 comments
Open

Documentation of signal.pause is incorrect #100557

teythoon opened this issue Dec 27, 2022 · 0 comments
Labels
docs Documentation in the Doc dir

Comments

@teythoon
Copy link

teythoon commented Dec 27, 2022

Documentation

The documentation of signal.pause just states "Wait until a signal arrives." which is incomplete to the point of being wrong: pause(2) only returns control if a signal is delivered which is not ignored by the process, see the POSIX documentation for pause.

This is easy to demonstrate. Run the following script and send SIGCHLD to it:

$ strace -e pause python3 -c 'import os; print(os.getpid()); import signal; signal.pause()'
2293354
pause()                                 = ? ERESTARTNOHAND (To be restarted if no handler)
--- SIGCHLD {si_signo=SIGCHLD, si_code=SI_USER, si_pid=2293315, si_uid=1000} ---
pause(

On the other hand, if we install a signal handler, SIGCHLD will make pause(2) return:

$ strace -e pause python3 -c 'import os; print(os.getpid()); import signal; signal.signal(signal.SIGCHLD, lambda sig, stack: None); signal.pause()'
2293525
pause()                                 = ? ERESTARTNOHAND (To be restarted if no handler)
--- SIGCHLD {si_signo=SIGCHLD, si_code=SI_USER, si_pid=2293315, si_uid=1000} ---
+++ exited with 0 +++
@teythoon teythoon added the docs Documentation in the Doc dir label Dec 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation in the Doc dir
Projects
None yet
Development

No branches or pull requests

1 participant