From 568044438d64016a7ebbdd1ba211742bf38017fb Mon Sep 17 00:00:00 2001 From: David Wilson Date: Wed, 30 Jan 2019 00:40:12 +0000 Subject: [PATCH] parent: don't kill children when profiling is active. --- mitogen/parent.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/mitogen/parent.py b/mitogen/parent.py index 241f6243..fc5433ed 100644 --- a/mitogen/parent.py +++ b/mitogen/parent.py @@ -1147,15 +1147,16 @@ class Stream(mitogen.core.Stream): LOG.debug('%r: PID %d %s', self, pid, wstatus_to_str(status)) return - # For processes like sudo we cannot actually send sudo a signal, - # because it is setuid, so this is best-effort only. - LOG.debug('%r: child process still alive, sending SIGTERM', self) - try: - os.kill(self.pid, signal.SIGTERM) - except OSError: - e = sys.exc_info()[1] - if e.args[0] != errno.EPERM: - raise + if not self._router.profiling: + # For processes like sudo we cannot actually send sudo a signal, + # because it is setuid, so this is best-effort only. + LOG.debug('%r: child process still alive, sending SIGTERM', self) + try: + os.kill(self.pid, signal.SIGTERM) + except OSError: + e = sys.exc_info()[1] + if e.args[0] != errno.EPERM: + raise def on_disconnect(self, broker): super(Stream, self).on_disconnect(broker)