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


Python signal.SIGSTOP属性代码示例

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


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

示例1: test_wait_stopped

# 需要导入模块: import signal [as 别名]
# 或者: from signal import SIGSTOP [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

示例2: _shocker_thread

# 需要导入模块: import signal [as 别名]
# 或者: from signal import SIGSTOP [as 别名]
def _shocker_thread(self):
        # On Linux, ignored signals still cause a notification under ptrace.
        # Hence, we use SIGWINCH, harmless and ignored signal to make wait4 return
        # pt_process::monitor, causing time to be updated.
        # On FreeBSD, a signal must not be ignored in order for wait4 to return.
        # Hence, we swallow SIGSTOP, which should never be used anyway, and use it
        # force an update.
        wake_signal = signal.SIGSTOP if 'freebsd' in sys.platform else signal.SIGWINCH
        self._spawned_or_errored.wait()

        while not self._died.wait(1):
            if self.execution_time > self._time or self.wall_clock_time > self._wall_time:
                log.warning('Shocker activated and killed %d', self.pid)
                self.kill()
                self._is_tle = True
                break
            try:
                os.killpg(self.pid, wake_signal)
            except OSError:
                pass 
开发者ID:DMOJ,项目名称:judge-server,代码行数:22,代码来源:tracer.py

示例3: handleInput

# 需要导入模块: import signal [as 别名]
# 或者: from signal import SIGSTOP [as 别名]
def handleInput(self, char):
        #log.msg('handling %s' % repr(char))
        if char in ('\n', '\r'):
            self.escapeMode = 1
            self.write(char)
        elif self.escapeMode == 1 and char == options['escape']:
            self.escapeMode = 2
        elif self.escapeMode == 2:
            self.escapeMode = 1 # so we can chain escapes together
            if char == '.': # disconnect
                log.msg('disconnecting from escape')
                reactor.stop()
                return
            elif char == '\x1a': # ^Z, suspend
                # following line courtesy of Erwin@freenode
                os.kill(os.getpid(), signal.SIGSTOP)
                return
            elif char == 'R': # rekey connection
                log.msg('rekeying connection')
                self.conn.transport.sendKexInit()
                return
            self.write('~' + char)
        else:
            self.escapeMode = 0
            self.write(char) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:27,代码来源:tkconch.py

示例4: _ptrace

# 需要导入模块: import signal [as 别名]
# 或者: from signal import SIGSTOP [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

示例5: add_signal_handler

# 需要导入模块: import signal [as 别名]
# 或者: from signal import SIGSTOP [as 别名]
def add_signal_handler(self, sig, callback, *args):
            self.remove_signal_handler(sig)

            s = GLib.unix_signal_source_new(sig)
            if s is None:
                # Show custom error messages for signal that are uncatchable
                if sig == signal.SIGKILL:
                    raise RuntimeError("cannot catch SIGKILL")
                elif sig == signal.SIGSTOP:
                    raise RuntimeError("cannot catch SIGSTOP")
                else:
                    raise ValueError("signal not supported")

            assert sig not in self._sighandlers

            self._sighandlers[sig] = GLibHandle(
                loop=self,
                source=s,
                repeat=True,
                callback=callback,
                args=args) 
开发者ID:pychess,项目名称:pychess,代码行数:23,代码来源:glib_events.py

示例6: _test_persistent

# 需要导入模块: import signal [as 别名]
# 或者: from signal import SIGSTOP [as 别名]
def _test_persistent(n, *args, **kwargs):
    os.environ['PYTHON_AFL_PERSISTENT'] = '1'
    n_max = 1000
    k = [0]
    def kill(pid, sig):
        assert_equal(pid, os.getpid())
        assert_equal(sig, signal.SIGSTOP)
        k[0] += 1
    os.kill = kill
    x = 0
    while afl.loop(*args, **kwargs):
        x += 1
        if x == n_max:
            break
    if n is None:
        n = n_max
    assert_equal(x, n)
    assert_equal(k[0], n - 1) 
开发者ID:jwilk,项目名称:python-afl,代码行数:20,代码来源:test_loop.py

示例7: execute

# 需要导入模块: import signal [as 别名]
# 或者: from signal import SIGSTOP [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

示例8: waitExit

# 需要导入模块: import signal [as 别名]
# 或者: from signal import SIGSTOP [as 别名]
def waitExit(self):
        debug("Wait %s exit" % self)
        while True:
            # Wait for any process signal
            event = self.waitEvent()
            event_cls = event.__class__

            # Process exited: we are done
            if event_cls == ProcessExit:
                debug(str(event))
                return

            # Event different than a signal? Raise an exception
            if event_cls != ProcessSignal:
                raise event

            # Send the signal to the process
            signum = event.signum
            if signum not in (SIGTRAP, SIGSTOP):
                self.cont(signum)
            else:
                self.cont() 
开发者ID:tuwid,项目名称:darkc0de-old-stuff,代码行数:24,代码来源:process.py

示例9: setup

# 需要导入模块: import signal [as 别名]
# 或者: from signal import SIGSTOP [as 别名]
def setup(self):
        self.parse_processes()
        for proc in self._processes.values():
            if proc["pid"] == os.getpid():
                continue
            if any(proc["comm"].startswith(pref) for pref in self.misc_settings["comm_prefixes_ignored"]):
                continue
            if proc["nice"] == "-" or int(proc["nice"]) < self.misc_settings["min_nice"]:
                continue
            suffixes = self.misc_settings["subtree_suffixes"]
            if any(proc["comm"].startswith(pref) for pref in self.misc_settings["comm_prefixes"]) or \
                    proc["pid"] >= self.misc_settings["min_id"] or \
                    any(any(pcomm.endswith(suff) for suff in suffixes) for pcomm in self._get_pcomms(proc["pid"])):
                if self.misc_settings["dry_run"]:
                    logging.info(self._proc_dict_to_str(proc))
                else:
                    self._pids.append(proc["pid"])
        if self.misc_settings["dry_run"]:
            raise KeyboardInterrupt()
        self._send_signal(signal.SIGSTOP) 
开发者ID:parttimenerd,项目名称:temci,代码行数:22,代码来源:run_driver_plugin.py

示例10: suspend

# 需要导入模块: import signal [as 别名]
# 或者: from signal import SIGSTOP [as 别名]
def suspend(prev_app):
    if name_of(prev_app) in DONT_SUSPEND_NAME:
        print(name_of(prev_app) + ' not suspended, in dont suspend list')
        return
    pids = get_pids(prev_app)
    logger.debug('Suspending %s (%s)', pids, name_of(prev_app))
    for pid in pids:
        SUSPENDED.add(pid)
        os.kill(int(pid), signal.SIGSTOP) 
开发者ID:omikun,项目名称:ForceNap,代码行数:11,代码来源:ForceNap.py

示例11: suspend

# 需要导入模块: import signal [as 别名]
# 或者: from signal import SIGSTOP [as 别名]
def suspend(self):
        '''
        Suspend application and all processes associated with it
        '''
        if self.name in SUSPENSION_WHITELIST:
            return

        for pid in self.get_pids():
            if pid not in suspended_pids:
                logger.debug('Suspending %s (%s)', self.pid, self.name)
                suspended_pids.add(pid)
                os.kill(pid, signal.SIGSTOP)
        return 
开发者ID:omikun,项目名称:ForceNap,代码行数:15,代码来源:nap_my_app.py

示例12: suspend

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

示例13: handlePosixSignal

# 需要导入模块: import signal [as 别名]
# 或者: from signal import SIGSTOP [as 别名]
def handlePosixSignal(self, sig):
        """
        Handle a basic posix signal for this trace.  This was seperated from
        platformProcessEvent so extenders could skim events and still use this logic.
        """
        if sig == signal.SIGTRAP:

            # Traps on posix systems are a little complicated
            if self.stepping:
                #FIXME try out was single step thing for intel
                self.stepping = False
                self.fireNotifiers(vtrace.NOTIFY_STEP)

            elif self.checkWatchpoints():
                return

            elif self.checkBreakpoints():
                # It was either a known BP or a sendBreak()
                return

            elif self.execing:
                self.execing = False
                self.handleAttach()

            else:
                self._fireSignal(sig)

        elif sig == signal.SIGSTOP:
            #FIXME only on attaching..
            self.handleAttach()

        else:
            self._fireSignal(sig) 
开发者ID:joxeankoret,项目名称:nightmare,代码行数:35,代码来源:posix.py

示例14: terminate_executor_shell_and_children

# 需要导入模块: import signal [as 别名]
# 或者: from signal import SIGSTOP [as 别名]
def terminate_executor_shell_and_children(pid):
    print('terminate_executor_shell_and_children+', pid)
    # If the shell already ends, no need to terminate its child.
    try:
        p = psutil.Process(pid)
    except psutil.NoSuchProcess:
        print('nosuchprocess')
        return

    # Terminate children gracefully.
    for child in p.children():
        try:
            child.terminate()
        except psutil.NoSuchProcess:
            pass

    # Wait for graceful termination.
    time.sleep(GRACEFUL_TERMINATION_TIME_S)

    # Send STOP to executor shell to stop progress.
    p.send_signal(signal.SIGSTOP)

    # Kill children recursively.
    for child in p.children(recursive=True):
        try:
            child.kill()
        except psutil.NoSuchProcess:
            pass

    # Kill shell itself.
    p.kill()
    print('terminate_executor_shell_and_children-', pid) 
开发者ID:kakaobrain,项目名称:fast-autoaugment,代码行数:34,代码来源:safe_shell_exec.py

示例15: stop

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


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