当前位置: 首页>>代码示例>>Python>>正文


Python signal.SIGCONT属性代码示例

本文整理汇总了Python中signal.SIGCONT属性的典型用法代码示例。如果您正苦于以下问题:Python signal.SIGCONT属性的具体用法?Python signal.SIGCONT怎么用?Python signal.SIGCONT使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在signal的用法示例。


在下文中一共展示了signal.SIGCONT属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: resume

# 需要导入模块: import signal [as 别名]
# 或者: from signal import SIGCONT [as 别名]
def resume(app):
    'Resume apps that have been suspended and arent on the do not suspend list'
    if name_of(app) in DONT_SUSPEND_NAME: 
        print(name_of(app) + ' not resumed, in dont suspend list')
        return
    pids = get_pids(app)
    for pid in pids:
        if pid in SUSPENDED:
            break
    else:
        return
    # only resume pids that are suspended
    logger.debug('Resuming %s (%s)', pids, name_of(app))
    for pid in pids:
        SUSPENDED.discard(pid)
        os.kill(int(pid), signal.SIGCONT)
    for pid in pids:
        os.kill(int(pid), signal.SIGCONT) 
开发者ID:omikun,项目名称:ForceNap,代码行数:20,代码来源:ForceNap.py

示例2: test_wait_stopped

# 需要导入模块: import signal [as 别名]
# 或者: from signal import SIGCONT [as 别名]
def test_wait_stopped(self):
        p = self.spawn_psproc()
        if POSIX:
            # Test waitpid() + WIFSTOPPED and WIFCONTINUED.
            # Note: if a process is stopped it ignores SIGTERM.
            p.send_signal(signal.SIGSTOP)
            self.assertRaises(psutil.TimeoutExpired, p.wait, timeout=0.001)
            p.send_signal(signal.SIGCONT)
            self.assertRaises(psutil.TimeoutExpired, p.wait, timeout=0.001)
            p.send_signal(signal.SIGTERM)
            self.assertEqual(p.wait(), -signal.SIGTERM)
            self.assertEqual(p.wait(), -signal.SIGTERM)
        else:
            p.suspend()
            self.assertRaises(psutil.TimeoutExpired, p.wait, timeout=0.001)
            p.resume()
            self.assertRaises(psutil.TimeoutExpired, p.wait, timeout=0.001)
            p.terminate()
            self.assertEqual(p.wait(), signal.SIGTERM)
            self.assertEqual(p.wait(), signal.SIGTERM) 
开发者ID:giampaolo,项目名称:psutil,代码行数:22,代码来源:test_process.py

示例3: _ptrace

# 需要导入模块: import signal [as 别名]
# 或者: from signal import SIGCONT [as 别名]
def _ptrace(self, attach):
        op = ctypes.c_int(PTRACE_ATTACH if attach else PTRACE_DETACH)
        c_pid = c_pid_t(self.pid)
        null = ctypes.c_void_p()

        if not attach:
            os.kill(self.pid, signal.SIGSTOP)
            os.waitpid(self.pid, 0)

        err = c_ptrace(op, c_pid, null, null)

        if not attach:
            os.kill(self.pid, signal.SIGCONT)

        if err != 0:
            raise OSError("%s: %s"%(
                'PTRACE_ATTACH' if attach else 'PTRACE_DETACH',
                errno.errorcode.get(ctypes.get_errno(), 'UNKNOWN')
            )) 
开发者ID:n1nj4sec,项目名称:memorpy,代码行数:21,代码来源:LinProcess.py

示例4: execute

# 需要导入模块: import signal [as 别名]
# 或者: from signal import SIGCONT [as 别名]
def execute(self,dt):
        if self.finished: return "finished"
        if not self.running:
            self.process = Process(target = executeInProcessGroup, args = (self,))
            self.process.start()
            print "timeshare child PID:",self.process.pid
            os.setpgid(self.process.pid,self.process.pid)
            print "timeshare process group",os.getpgid(self.process.pid)
            assert os.getpgid(self.process.pid) == self.process.pid
            print "my process group",os.getpgrp(),"which should be",os.getpgid(0)
            assert os.getpgid(self.process.pid) != os.getpgid(0)
            self.running = True
        else:
            os.killpg(self.process.pid, signal.SIGCONT)
        
        self.process.join(dt)
        if self.process.is_alive():
            os.killpg(self.process.pid, signal.SIGSTOP)
            return "still running"
        else:
            self.finished = True
            return self.q.get() 
开发者ID:ellisk42,项目名称:TikZ,代码行数:24,代码来源:timeshare.py

示例5: test_shell_background_support_setsid

# 需要导入模块: import signal [as 别名]
# 或者: from signal import SIGCONT [as 别名]
def test_shell_background_support_setsid():
    """In setsid mode, dumb-init should suspend itself and its children when it
    receives SIGTSTP, SIGTTOU, or SIGTTIN.
    """
    with print_signals() as (proc, pid):
        for signum in SUSPEND_SIGNALS:
            # both dumb-init and print_signals should be running or sleeping
            assert process_state(pid) in ['running', 'sleeping']
            assert process_state(proc.pid) in ['running', 'sleeping']

            # both should now suspend
            proc.send_signal(signum)

            def assert_both_stopped():
                assert process_state(proc.pid) == process_state(pid) == 'stopped'

            sleep_until(assert_both_stopped)

            # and then both wake up again
            proc.send_signal(SIGCONT)
            assert (
                proc.stdout.readline() == '{}\n'.format(SIGCONT).encode('ascii')
            )
            assert process_state(pid) in ['running', 'sleeping']
            assert process_state(proc.pid) in ['running', 'sleeping'] 
开发者ID:Yelp,项目名称:dumb-init,代码行数:27,代码来源:shell_background_test.py

示例6: test_shell_background_support_without_setsid

# 需要导入模块: import signal [as 别名]
# 或者: from signal import SIGCONT [as 别名]
def test_shell_background_support_without_setsid():
    """In non-setsid mode, dumb-init should forward the signals SIGTSTP,
    SIGTTOU, and SIGTTIN, and then suspend itself.
    """
    with print_signals() as (proc, _):
        for signum in SUSPEND_SIGNALS:
            assert process_state(proc.pid) in ['running', 'sleeping']
            proc.send_signal(signum)
            assert proc.stdout.readline() == '{}\n'.format(signum).encode('ascii')
            os.waitpid(proc.pid, os.WUNTRACED)
            assert process_state(proc.pid) == 'stopped'

            proc.send_signal(SIGCONT)
            assert (
                proc.stdout.readline() == '{}\n'.format(SIGCONT).encode('ascii')
            )
            assert process_state(proc.pid) in ['running', 'sleeping'] 
开发者ID:Yelp,项目名称:dumb-init,代码行数:19,代码来源:shell_background_test.py

示例7: test_default_rewrites_can_be_overriden_with_setsid_enabled

# 需要导入模块: import signal [as 别名]
# 或者: from signal import SIGCONT [as 别名]
def test_default_rewrites_can_be_overriden_with_setsid_enabled():
    """In setsid mode, dumb-init should allow overwriting the default
    rewrites (but still suspend itself).
    """
    rewrite_map = {
        signal.SIGTTIN: signal.SIGTERM,
        signal.SIGTTOU: signal.SIGINT,
        signal.SIGTSTP: signal.SIGHUP,
    }
    with print_signals(_rewrite_map_to_args(rewrite_map)) as (proc, _):
        for send, expect_receive in rewrite_map.items():
            assert process_state(proc.pid) in ['running', 'sleeping']
            proc.send_signal(send)

            assert proc.stdout.readline() == '{}\n'.format(expect_receive).encode('ascii')
            os.waitpid(proc.pid, os.WUNTRACED)
            assert process_state(proc.pid) == 'stopped'

            proc.send_signal(signal.SIGCONT)
            assert proc.stdout.readline() == '{}\n'.format(signal.SIGCONT).encode('ascii')
            assert process_state(proc.pid) in ['running', 'sleeping'] 
开发者ID:Yelp,项目名称:dumb-init,代码行数:23,代码来源:proxies_signals_test.py

示例8: resume

# 需要导入模块: import signal [as 别名]
# 或者: from signal import SIGCONT [as 别名]
def resume(self, unique_id, configs=None):
    """ Issues a sigcont for the specified process

    :Parameter unique_id: the name of the process
    """
    self._send_signal(unique_id, signal.SIGCONT,configs) 
开发者ID:linkedin,项目名称:Zopkio,代码行数:8,代码来源:deployer.py

示例9: clean_exit

# 需要导入模块: import signal [as 别名]
# 或者: from signal import SIGCONT [as 别名]
def clean_exit():
    for pid in SUSPENDED:
        os.kill(int(pid), signal.SIGCONT) 
开发者ID:omikun,项目名称:ForceNap,代码行数:5,代码来源:ForceNap.py

示例10: resume

# 需要导入模块: import signal [as 别名]
# 或者: from signal import SIGCONT [as 别名]
def resume(self):
        '''
        Resume application and all processes associated with it
        '''
        for pid in self.get_pids():
            if pid in suspended_pids:
                logger.debug('Resuming %s (%s)', self.pid, self.name)
                suspended_pids.discard(pid)
                os.kill(pid, signal.SIGCONT)
        return 
开发者ID:omikun,项目名称:ForceNap,代码行数:12,代码来源:nap_my_app.py

示例11: resume

# 需要导入模块: import signal [as 别名]
# 或者: from signal import SIGCONT [as 别名]
def resume(self):
        """Resume process execution with SIGCONT pre-emptively checking
        whether PID has been reused.
        On Windows this has the effect of resuming all process threads.
        """
        if POSIX:
            self._send_signal(signal.SIGCONT)
        else:  # pragma: no cover
            self._proc.resume() 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:11,代码来源:__init__.py

示例12: terminate

# 需要导入模块: import signal [as 别名]
# 或者: from signal import SIGCONT [as 别名]
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 as 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 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:42,代码来源:_pexpect.py

示例13: terminate

# 需要导入模块: import signal [as 别名]
# 或者: from signal import SIGCONT [as 别名]
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 
开发者ID:pypa,项目名称:pipenv,代码行数:41,代码来源:ptyprocess.py

示例14: cont

# 需要导入模块: import signal [as 别名]
# 或者: from signal import SIGCONT [as 别名]
def cont(self):
        os.kill(self.childpid, SIGCONT)
        self.deadchild = 0 
开发者ID:kdart,项目名称:pycopia,代码行数:5,代码来源:proctools.py

示例15: terminate

# 需要导入模块: import signal [as 别名]
# 或者: from signal import SIGCONT [as 别名]
def terminate(self, force = True):
		"""Send a signal to the process in the pty"""
		if self.proc.isalive():

			if os.name == 'nt':
				signals = [signal.SIGINT, signal.SIGTERM]
			else:
				signals = [signal.SIGHUP, signal.SIGCONT, signal.SIGINT,
						   signal.SIGTERM]

			try:
				for sig in signals:
					self.proc.kill(sig)

					if not self.proc.isalive():
						return True

				if force:
					self.proc.kill(signal.SIGKILL)

					if not self.proc.isalive():
						return True

				return False

			except Exception as e:
				if self.proc.isalive():
					return False

		return True 
开发者ID:turingsec,项目名称:marsnake,代码行数:32,代码来源:ptys.py


注:本文中的signal.SIGCONT属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。