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
forkserver process should silence KeyboardInterrupt #74371
Comments
The forkserver intermediate process is an implementation detail. However, if you Ctrl-C the main process, the forkserver process will exit with a KeyboardInterrupt traceback, even if the main process catches KeyboardInterrupt to exit silently. This produces stderr such as: $ ./python forkserversignal.py
^CTraceback (most recent call last):
File "<string>", line 1, in <module>
File "/home/antoine/cpython/default/Lib/multiprocessing/forkserver.py", line 164, in main
rfds = [key.fileobj for (key, events) in selector.select()]
File "/home/antoine/cpython/default/Lib/selectors.py", line 445, in select
fd_event_list = self._epoll.poll(timeout, max_ev)
KeyboardInterrupt For the sake of usability, forkserver should probably silence those tracebacks by default, for example by changing the default signal handler in the forkserver process (but children forked by the forkserver process should probably get the default Python signal handlers...). Not sure this can be considered a bugfix or an enhancement. |
Uploading small reproducer script. |
A simpler solution would actually be to catch KeyboardInterrupt inside the forkserver loop and exit cleanly... |
I'm not sure that we always want to exit on CTRL-c. But I agree that the forkserver has to handle CTRL-c. Maybe ignore it, but be killed when its master gets a CTRL-c? |
That's what the forkserver does right now, it's just that it does it with a traceback that's useless to the user.
That's a possibility (the forkserver should already exit automatically when its parent dies), the problem is what to do for the forkserver's children? Should they restore the default signal handler? Simply silencing the KeyboardInterrupt traceback at least is a straightforward solution with little risk of side effects. |
Python 2.7 isn't affected by this bug? |
There is no forkserver in 2.7. |
Oh right, it's specific to forkserver, ok ;-) Thank you for the fix. |
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:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: