def kill(self):
        if not self.childPid:
            self.childPid = None
            return

        if os.environ.get('COVERAGE_DIR', None):
            sendsig = signal.SIGUSR2
        else:
            sendsig = signal.SIGTERM

        start = time.time()
        while True:
            now = time.time()
            if start - now > 15:
                break

            os.kill(self.childPid, sendsig)
            try:
                pid = os.waitpid(self.childPid, os.WNOHANG)[0]
            except OSError, err:
                if err.errno == errno.EINTR:
                    # Interrupted.
                    continue
                elif err.errno == errno.ECHILD:
                    # Process doesn't exist.
                    self.childPid = None
                    return
                else:
                    raise
            else:
                if pid:
                    # Process existed but is now gone.
                    self.childPid = None
                    return
                # Process exists and is still running.
                time.sleep(2)

        # Process still not dead.
        os.kill(self.childPid, signal.SIGKILL)
        os.waitpid(self.childPid, 0)
        self.childPid = None
dataset/ETHPy150Open sassoftware/conary/conary_test/rephelp.py/HTTPServerController.kill/swapped operands of `-`