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 +++
Linked PRs
Documentation
The documentation of
signal.pausejust 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:
On the other hand, if we install a signal handler, SIGCHLD will make pause(2) return:
Linked PRs