python类SIGCONT的实例源码

sandbox.py 文件源码 项目:hackman-standalone 作者: smiley1983 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def resume(self):
        """Resume the process by sending a SIGCONT to the child

        This method is a no-op on Windows
        """
        try:
            self.command_process.send_signal(signal.SIGCONT)
        except (ValueError, AttributeError, OSError):
            pass
sandbox.py 文件源码 项目:uttt_engine_standalone 作者: smiley1983 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def resume(self):
        """Resume the process by sending a SIGCONT to the child"""
        try:
            self.command_process.stdin.write("CONT\n")
            self.command_process.stdin.flush()
        except IOError as exc:
            if exc.errno == 32: # Broken pipe, guard exited
                return
            raise
        item = self.resp_queue.get()
        if item[1] != "CONT" and item[1] is not None:
            raise SandboxError("Bad response from jailguard after resume, %s"
                    % (item,))
pty_spawn.py 文件源码 项目:yatta_reader 作者: sound88 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
def terminate(self, force=False):
        '''This forces a child process to terminate. It starts nicely with
        SIGHUP and SIGINT. If "force" is True then moves onto SIGKILL. This
        returns True if the child was terminated. This returns False if the
        child could not be terminated. '''

        if not self.isalive():
            return True
        try:
            self.kill(signal.SIGHUP)
            time.sleep(self.delayafterterminate)
            if not self.isalive():
                return True
            self.kill(signal.SIGCONT)
            time.sleep(self.delayafterterminate)
            if not self.isalive():
                return True
            self.kill(signal.SIGINT)
            time.sleep(self.delayafterterminate)
            if not self.isalive():
                return True
            if force:
                self.kill(signal.SIGKILL)
                time.sleep(self.delayafterterminate)
                if not self.isalive():
                    return True
                else:
                    return False
            return False
        except OSError:
            # I think there are kernel timing issues that sometimes cause
            # this to happen. I think isalive() reports True, but the
            # process is dead to the kernel.
            # Make one last attempt to see if the kernel is up to date.
            time.sleep(self.delayafterterminate)
            if not self.isalive():
                return True
            else:
                return False
ptyprocess.py 文件源码 项目:yatta_reader 作者: sound88 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def terminate(self, force=False):
        '''This forces a child process to terminate. It starts nicely with
        SIGHUP and SIGINT. If "force" is True then moves onto SIGKILL. This
        returns True if the child was terminated. This returns False if the
        child could not be terminated. '''

        if not self.isalive():
            return True
        try:
            self.kill(signal.SIGHUP)
            time.sleep(self.delayafterterminate)
            if not self.isalive():
                return True
            self.kill(signal.SIGCONT)
            time.sleep(self.delayafterterminate)
            if not self.isalive():
                return True
            self.kill(signal.SIGINT)
            time.sleep(self.delayafterterminate)
            if not self.isalive():
                return True
            if force:
                self.kill(signal.SIGKILL)
                time.sleep(self.delayafterterminate)
                if not self.isalive():
                    return True
                else:
                    return False
            return False
        except OSError:
            # I think there are kernel timing issues that sometimes cause
            # this to happen. I think isalive() reports True, but the
            # process is dead to the kernel.
            # Make one last attempt to see if the kernel is up to date.
            time.sleep(self.delayafterterminate)
            if not self.isalive():
                return True
            else:
                return False
__init__.py 文件源码 项目:tools 作者: InfraSIM 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def terminate(self, force=False):

        '''This forces a child process to terminate. It starts nicely with
        SIGHUP and SIGINT. If "force" is True then moves onto SIGKILL. This
        returns True if the child was terminated. This returns False if the
        child could not be terminated. '''

        if not self.isalive():
            return True
        try:
            self.kill(signal.SIGHUP)
            time.sleep(self.delayafterterminate)
            if not self.isalive():
                return True
            self.kill(signal.SIGCONT)
            time.sleep(self.delayafterterminate)
            if not self.isalive():
                return True
            self.kill(signal.SIGINT)
            time.sleep(self.delayafterterminate)
            if not self.isalive():
                return True
            if force:
                self.kill(signal.SIGKILL)
                time.sleep(self.delayafterterminate)
                if not self.isalive():
                    return True
                else:
                    return False
            return False
        except OSError:
            # I think there are kernel timing issues that sometimes cause
            # this to happen. I think isalive() reports True, but the
            # process is dead to the kernel.
            # Make one last attempt to see if the kernel is up to date.
            time.sleep(self.delayafterterminate)
            if not self.isalive():
                return True
            else:
                return False
pexpect23.py 文件源码 项目:sardana 作者: sardana-org 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def terminate(self, force=False):
        """This forces a child process to terminate. It starts nicely with
        SIGHUP and SIGINT. If "force" is True then moves onto SIGKILL. This
        returns True if the child was terminated. This returns False if the
        child could not be terminated. """

        if not self.isalive():
            return True
        try:
            self.kill(signal.SIGHUP)
            time.sleep(self.delayafterterminate)
            if not self.isalive():
                return True
            self.kill(signal.SIGCONT)
            time.sleep(self.delayafterterminate)
            if not self.isalive():
                return True
            self.kill(signal.SIGINT)
            time.sleep(self.delayafterterminate)
            if not self.isalive():
                return True
            if force:
                self.kill(signal.SIGKILL)
                time.sleep(self.delayafterterminate)
                if not self.isalive():
                    return True
                else:
                    return False
            return False
        except OSError, e:
            # I think there are kernel timing issues that sometimes cause
            # this to happen. I think isalive() reports True, but the
            # process is dead to the kernel.
            # Make one last attempt to see if the kernel is up to date.
            time.sleep(self.delayafterterminate)
            if not self.isalive():
                return True
            else:
                return False
base.py 文件源码 项目:slug 作者: xonsh 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def signal(self, sig):
        """
        Signal the process of an event.
        """
        if sig == signal.SIGKILL:
            self.kill()
        elif sig == signal.SIGTERM:
            self.terminate()
        elif sig == signal.SIGSTOP:
            self.pause()
        elif sig == signal.SIGCONT:
            self.unpause()
        else:
            self.on_signal(sig)
posix.py 文件源码 项目:slug 作者: xonsh 项目源码 文件源码 阅读 33 收藏 0 点赞 0 评论 0
def unpause(self):
        # continue is a reserved word
        """
        Continue the process after it's been paused
        """
        self.signal(signal.SIGCONT)
ngamsDaemon.py 文件源码 项目:ngas 作者: ICRAR 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
def kill_and_wait(pid, pidfile):

    # The NGAS server should nicely shut down itself after receiving this signal
    os.kill(pid, signal.SIGTERM)

    # We previously checked that the pidfile was gone, but this is not enough
    # In some cases the main thread finished correctly, but there are other
    # threads (e.g., HTTP servicing threads) that are still running,
    # and thus the PID file disappears but the process is still ongoing
    tries = 0
    max_tries = 20
    sleep_period = 1
    start = time.time()
    while tries < max_tries:

        # SIGCONT can be sent many times without fear of side effects
        # If we get ESRCH then the process has finished
        try:
            os.kill(pid, signal.SIGCONT)
        except OSError as e:
            if e.errno == errno.ESRCH:
                # Bingo! the process is gone
                break

        tries += 1
        time.sleep(sleep_period)
        sys.stdout.write('.')
        sys.stdout.flush()

    sys.stdout.write('\n')
    sys.stdout.flush()
    end = time.time()

    ret = 0x00

    # We waited a lot but the process is still there, kill it with 9
    if tries == max_tries:
        err("Process didn't die after %.2f [s], killing it with -9" % (end-start))
        os.kill(pid, signal.SIGKILL)
        ret += 0x01

    # The process should have removed its own pidfile...
    if os.path.exists(pidfile):
        err("Removing PID file manually, the daemon process didn't remove it by itself")
        os.unlink(pidfile)
        ret += 0x02

    return ret


问题


面经


文章

微信
公众号

扫码关注公众号