issue #241: child main thread does not gracefully handle CTRL+C

In Ansible, depending on when CTRL+C is triggered, if it occurs after
the connection multiplexer process has forked, and after it has in turn
forked the "connection: local" context and its corresponding "clean fork
parent", since all the broker processes still belong to Ansible's
terminal foreground process group, they are all capable of receiving
SIGINT in response to CTRL+C being pressed on that terminal.

This papers over the problem. Really we want those KeyboardInterrupts to
be logged, to call setsid() frmo the connection multiplexer process to
isolate it from the terminal foreground process group. That way its only
indication of top-level process shutdown is using the graceful
disconnect mechanism that already exists in process.py::worker_main().
This commit is contained in:
David Wilson 2018-05-02 16:51:50 +01:00
parent 9cc8b21a07
commit 92a2565507
1 changed files with 2 additions and 0 deletions

View File

@ -1684,6 +1684,8 @@ class ExternalContext(object):
_profile_hook('main', self._dispatch_calls)
_v and LOG.debug('ExternalContext.main() normal exit')
except KeyboardInterrupt:
LOG.debug('KeyboardInterrupt received, exiting gracefully.')
except BaseException:
LOG.exception('ExternalContext.main() crashed')
raise