Skip to content
Browse files

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
  • Loading branch information...
dw committed May 2, 2018
1 parent 9cc8b21 commit 92a25655078a06facf3e6c34217bcd1de1272738
Showing with 2 additions and 0 deletions.
  1. +2 −0 mitogen/
@@ -1684,6 +1684,8 @@ def main(self, parent_ids, context_id, debug, profiling, log_level,

_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')

0 comments on commit 92a2565

Please sign in to comment.
You can’t perform that action at this time.