當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。