'Replacement function for handling received signals.
Store the received signal. If we are executing the code block in
the body of the context manager, stop by raising signal exit.
:param int signum: number of current signal'

def _signal_handler(self, signum, unused_frame):

    self.received_signals.append(signum)
    if (not self.body_executed):
        raise errors.SignalExit
