本文整理汇总了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)
示例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)
示例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')
))
示例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()
示例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']
示例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']
示例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']
示例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)
示例9: clean_exit
# 需要导入模块: import signal [as 别名]
# 或者: from signal import SIGCONT [as 别名]
def clean_exit():
for pid in SUSPENDED:
os.kill(int(pid), signal.SIGCONT)
示例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
示例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()
示例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
示例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
示例14: cont
# 需要导入模块: import signal [as 别名]
# 或者: from signal import SIGCONT [as 别名]
def cont(self):
os.kill(self.childpid, SIGCONT)
self.deadchild = 0
示例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