當前位置: 首頁>>代碼示例>>Python>>正文


Python os.WIFSTOPPED屬性代碼示例

本文整理匯總了Python中os.WIFSTOPPED屬性的典型用法代碼示例。如果您正苦於以下問題:Python os.WIFSTOPPED屬性的具體用法?Python os.WIFSTOPPED怎麽用?Python os.WIFSTOPPED使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在os的用法示例。


在下文中一共展示了os.WIFSTOPPED屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: platformProcessEvent

# 需要導入模塊: import os [as 別名]
# 或者: from os import WIFSTOPPED [as 別名]
def platformProcessEvent(self, status):
        # Skim some linux specific events before passing to posix
        tid = self.getMeta("ThreadId", -1)
        if os.WIFSTOPPED(status):
            sig = status >> 8
            if sig == SIG_LINUX_SYSCALL:
                self.fireNotifiers(vtrace.NOTIFY_SYSCALL)

            elif sig == SIG_LINUX_CLONE:
                # Handle a new thread here!
                newtid = self.getPtraceEvent()
                self.attachThread(newtid, attached=True)

            #FIXME eventually implement child catching!
            else:
                self.handlePosixSignal(sig)

            return

        v_posix.PosixMixin.platformProcessEvent(self, status) 
開發者ID:joxeankoret,項目名稱:nightmare,代碼行數:22,代碼來源:linux.py

示例2: platformProcessEvent

# 需要導入模塊: import os [as 別名]
# 或者: from os import WIFSTOPPED [as 別名]
def platformProcessEvent(self, status):

        if os.WIFEXITED(status):
            tid = self.getMeta("ThreadId", -1)
            if tid != self.getPid():
                # Set the selected thread ID to the pid cause
                # the old one's invalid
                if tid in self.pthreads:
                    self.pthreads.remove(tid)
                self.setMeta("ThreadId", self.getPid())
                self._fireExitThread(tid, os.WEXITSTATUS(status))
            else:
                self._fireExit(os.WEXITSTATUS(status))

        elif os.WIFSIGNALED(status):
            self.setMeta("ExitCode", os.WTERMSIG(status))
            self.fireNotifiers(vtrace.NOTIFY_EXIT)

        elif os.WIFSTOPPED(status):
            sig = os.WSTOPSIG(status)
            self.handlePosixSignal(sig)

        else:
            print "OMG WTF JUST HAPPENED??!?11/!?1?>!" 
開發者ID:joxeankoret,項目名稱:nightmare,代碼行數:26,代碼來源:posix.py

示例3: _handle_exitstatus

# 需要導入模塊: import os [as 別名]
# 或者: from os import WIFSTOPPED [as 別名]
def _handle_exitstatus(self, sts, _WIFSIGNALED=os.WIFSIGNALED,
                _WTERMSIG=os.WTERMSIG, _WIFEXITED=os.WIFEXITED,
                _WEXITSTATUS=os.WEXITSTATUS, _WIFSTOPPED=os.WIFSTOPPED,
                _WSTOPSIG=os.WSTOPSIG):
            """All callers to this function MUST hold self._waitpid_lock."""
            # This method is called (indirectly) by __del__, so it cannot
            # refer to anything outside of its local scope.
            if _WIFSIGNALED(sts):
                self.returncode = -_WTERMSIG(sts)
            elif _WIFEXITED(sts):
                self.returncode = _WEXITSTATUS(sts)
            elif _WIFSTOPPED(sts):
                self.returncode = -_WSTOPSIG(sts)
            else:
                # Should never happen
                raise SubprocessError("Unknown child exit status!") 
開發者ID:CedricGuillemet,項目名稱:Imogen,代碼行數:18,代碼來源:subprocess.py

示例4: _handle_exitstatus

# 需要導入模塊: import os [as 別名]
# 或者: from os import WIFSTOPPED [as 別名]
def _handle_exitstatus(self, sts, _WIFSIGNALED=os.WIFSIGNALED,
                _WTERMSIG=os.WTERMSIG, _WIFEXITED=os.WIFEXITED,
                _WEXITSTATUS=os.WEXITSTATUS, _WIFSTOPPED=os.WIFSTOPPED,
                _WSTOPSIG=os.WSTOPSIG):
            """All callers to this function MUST hold self._waitpid_lock."""
            # This method is called (indirectly) by __del__, so it cannot
            # refer to anything outside of its local scope."""
            if _WIFSIGNALED(sts):
                self.returncode = -_WTERMSIG(sts)
            elif _WIFEXITED(sts):
                self.returncode = _WEXITSTATUS(sts)
            elif _WIFSTOPPED(sts):
                self.returncode = -_WSTOPSIG(sts)
            else:
                # Should never happen
                raise RuntimeError("Unknown child exit status!") 
開發者ID:alvarobartt,項目名稱:twitter-stock-recommendation,代碼行數:18,代碼來源:subprocess32.py

示例5: _handle_exitstatus

# 需要導入模塊: import os [as 別名]
# 或者: from os import WIFSTOPPED [as 別名]
def _handle_exitstatus(self, sts, _WIFSIGNALED=os.WIFSIGNALED,
                _WTERMSIG=os.WTERMSIG, _WIFEXITED=os.WIFEXITED,
                _WEXITSTATUS=os.WEXITSTATUS, _WIFSTOPPED=os.WIFSTOPPED,
                _WSTOPSIG=os.WSTOPSIG):
            # This method is called (indirectly) by __del__, so it cannot
            # refer to anything outside of its local scope.
            if _WIFSIGNALED(sts):
                self.returncode = -_WTERMSIG(sts)
            elif _WIFEXITED(sts):
                self.returncode = _WEXITSTATUS(sts)
            elif _WIFSTOPPED(sts):
                self.returncode = -_WSTOPSIG(sts)
            else:
                # Should never happen
                raise RuntimeError("Unknown child exit status!") 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:17,代碼來源:subprocess.py

示例6: wait

# 需要導入模塊: import os [as 別名]
# 或者: from os import WIFSTOPPED [as 別名]
def wait(self):

        """This waits until the child exits. This is a blocking call. This will
        not read any data from the child, so this will block forever if the
        child has unread output and has terminated. In other words, the child
        may have printed output then called exit(); but, technically, the child
        is still alive until its output is read. """

        if self.isalive():
            pid, status = os.waitpid(self.pid, 0)
        else:
            raise ExceptionPexpect ('Cannot wait for dead child process.')
        self.exitstatus = os.WEXITSTATUS(status)
        if os.WIFEXITED (status):
            self.status = status
            self.exitstatus = os.WEXITSTATUS(status)
            self.signalstatus = None
            self.terminated = True
        elif os.WIFSIGNALED (status):
            self.status = status
            self.exitstatus = None
            self.signalstatus = os.WTERMSIG(status)
            self.terminated = True
        elif os.WIFSTOPPED (status):
            raise ExceptionPexpect ('Wait was called for a child process that is stopped. This is not supported. Is some other process attempting job control with our child pid?')
        return self.exitstatus 
開發者ID:ktraunmueller,項目名稱:Computable,代碼行數:28,代碼來源:_pexpect.py

示例7: wait

# 需要導入模塊: import os [as 別名]
# 或者: from os import WIFSTOPPED [as 別名]
def wait(self):
        '''This waits until the child exits. This is a blocking call. This will
        not read any data from the child, so this will block forever if the
        child has unread output and has terminated. In other words, the child
        may have printed output then called exit(), but, the child is
        technically still alive until its output is read by the parent. '''

        if self.isalive():
            pid, status = os.waitpid(self.pid, 0)
        else:
            return self.exitstatus
        self.exitstatus = os.WEXITSTATUS(status)
        if os.WIFEXITED(status):
            self.status = status
            self.exitstatus = os.WEXITSTATUS(status)
            self.signalstatus = None
            self.terminated = True
        elif os.WIFSIGNALED(status):
            self.status = status
            self.exitstatus = None
            self.signalstatus = os.WTERMSIG(status)
            self.terminated = True
        elif os.WIFSTOPPED(status):  # pragma: no cover
            # You can't call wait() on a child process in the stopped state.
            raise PtyProcessError('Called wait() on a stopped child ' +
                    'process. This is not supported. Is some other ' +
                    'process attempting job control with our child pid?')
        return self.exitstatus 
開發者ID:pypa,項目名稱:pipenv,代碼行數:30,代碼來源:ptyprocess.py

示例8: __init__

# 需要導入模塊: import os [as 別名]
# 或者: from os import WIFSTOPPED [as 別名]
def __init__(self, cmdline, sts):
        self.cmdline = cmdline
        if os.WIFEXITED(sts):
            self.state = 1
            self._status = self._es = os.WEXITSTATUS(sts)

        elif os.WIFSTOPPED(sts):
            self.state = 2
            self._status = self.stopsig = os.WSTOPSIG(sts)

        elif os.WIFSIGNALED(sts):
            self.state = 3
            self._status = self.termsig = os.WTERMSIG(sts) 
開發者ID:kdart,項目名稱:pycopia,代碼行數:15,代碼來源:exitstatus.py

示例9: WPTRACEEVENT

# 需要導入模塊: import os [as 別名]
# 或者: from os import WIFSTOPPED [as 別名]
def WPTRACEEVENT(status):
    if os.WIFSTOPPED(status):
        stopsig = os.WSTOPSIG(status)
        if stopsig == signal.SIGTRAP:
            return status >> 16

    return 0 
開發者ID:pinterest,項目名稱:ptracer,代碼行數:9,代碼來源:_defs_linux.py

示例10: wait

# 需要導入模塊: import os [as 別名]
# 或者: from os import WIFSTOPPED [as 別名]
def wait(self):

        '''This waits until the child exits. This is a blocking call. This will
        not read any data from the child, so this will block forever if the
        child has unread output and has terminated. In other words, the child
        may have printed output then called exit(), but, the child is
        technically still alive until its output is read by the parent. '''

        if self.isalive():
            pid, status = os.waitpid(self.pid, 0)
        else:
            raise ExceptionPexpect('Cannot wait for dead child process.')
        self.exitstatus = os.WEXITSTATUS(status)
        if os.WIFEXITED(status):
            self.status = status
            self.exitstatus = os.WEXITSTATUS(status)
            self.signalstatus = None
            self.terminated = True
        elif os.WIFSIGNALED(status):
            self.status = status
            self.exitstatus = None
            self.signalstatus = os.WTERMSIG(status)
            self.terminated = True
        elif os.WIFSTOPPED(status):  # pragma: no cover
            # You can't call wait() on a child process in the stopped state.
            raise ExceptionPexpect('Called wait() on a stopped child ' +
                    'process. This is not supported. Is some other ' +
                    'process attempting job control with our child pid?')
        return self.exitstatus 
開發者ID:c-amr,項目名稱:camr,代碼行數:31,代碼來源:__init__.py

示例11: status_msg

# 需要導入模塊: import os [as 別名]
# 或者: from os import WIFSTOPPED [as 別名]
def status_msg(status):
    """Given 'status', which is a process status in the form reported by
    waitpid(2) and returned by process_status(), returns a string describing
    how the process terminated."""
    if os.WIFEXITED(status):
        s = "exit status %d" % os.WEXITSTATUS(status)
    elif os.WIFSIGNALED(status):
        s = _signal_status_msg("killed", os.WTERMSIG(status))
    elif os.WIFSTOPPED(status):
        s = _signal_status_msg("stopped", os.WSTOPSIG(status))
    else:
        s = "terminated abnormally (%x)" % status
    if os.WCOREDUMP(status):
        s += ", core dumped"
    return s 
開發者ID:OpenState-SDN,項目名稱:ryu,代碼行數:17,代碼來源:process.py

示例12: _convert_exit_status

# 需要導入模塊: import os [as 別名]
# 或者: from os import WIFSTOPPED [as 別名]
def _convert_exit_status(status):
    """
    Convert a :func:`os.waitpid`-style exit status to a :mod:`subprocess` style
    exit status.
    """
    if os.WIFEXITED(status):
        return os.WEXITSTATUS(status)
    elif os.WIFSIGNALED(status):
        return -os.WTERMSIG(status)
    elif os.WIFSTOPPED(status):
        return -os.WSTOPSIG(status) 
開發者ID:dw,項目名稱:mitogen,代碼行數:13,代碼來源:fork.py

示例13: run

# 需要導入模塊: import os [as 別名]
# 或者: from os import WIFSTOPPED [as 別名]
def run(self):
        while not self.exit:
            self.in_queue_lock.acquire()
            if not self.in_queue.empty():
                cs = self.in_queue.get()
                self.in_queue_lock.release()

                cmd = self.target_cmd.replace("@@", os.path.abspath(cs))
                cs_fd = open(os.path.abspath(cs))
                try:
                    if afl_utils.afl_collect.stdin_mode(self.target_cmd):
                        v = subprocess.call(cmd.split(), stdin=cs_fd, stderr=subprocess.DEVNULL,
                                            stdout=subprocess.DEVNULL, timeout=self.timeout_secs)
                    else:
                        v = subprocess.call(cmd.split(), stderr=subprocess.DEVNULL,
                                            stdout=subprocess.DEVNULL, timeout=self.timeout_secs)
                    # check if process was terminated/stopped by signal
                    if not os.WIFSIGNALED(v) and not os.WIFSTOPPED(v):
                        self.out_queue_lock.acquire()
                        self.out_queue.put((cs, 'invalid'))
                        self.out_queue_lock.release()
                    else:
                        # need extension (add uninteresting signals):
                        # following signals don't indicate hard crashes: 1
                        # os.WTERMSIG(v) ?= v & 0x7f ???
                        if (os.WTERMSIG(v) or os.WSTOPSIG(v)) in [1]:
                            self.out_queue_lock.acquire()
                            self.out_queue.put((cs, 'invalid'))
                            self.out_queue_lock.release()
                        # debug
                        # else:
                        #     if os.WIFSIGNALED(v):
                        #         print("%s: sig: %d (%d)" % (cs, os.WTERMSIG(v), v))
                        #     elif os.WIFSTOPPED(v):
                        #         print("%s: sig: %d (%d)" % (cs, os.WSTOPSIG(v), v))
                except subprocess.TimeoutExpired:
                    self.out_queue_lock.acquire()
                    self.out_queue.put((cs, 'timeout'))
                    self.out_queue_lock.release()
                except Exception:
                    pass
                cs_fd.close()
            else:
                self.in_queue_lock.release()
                self.exit = True 
開發者ID:rc0r,項目名稱:afl-utils,代碼行數:47,代碼來源:AflThread.py

示例14: _wait_for_trace_stop

# 需要導入模塊: import os [as 別名]
# 或者: from os import WIFSTOPPED [as 別名]
def _wait_for_trace_stop(pid):
    try:
        # First, check if the tracee is already stopped.
        siginfo = getsiginfo(pid)
    except OSError as e:
        if e.errno == errno.ESRCH:
            # The tracee is still running, so we'll wait
            pass
        else:
            raise
    else:
        # Normally, PTRACE_ATTACH will send a SIGSTOP to the tracee,
        # which we will see here.  However, on some kernels the actual
        # signal may sometimes be SIGTRAP, and that seems to happen
        # when the previous tracer had died without calling PTRACE_DETACH
        # on this process first.  In this case, we need to restart the process
        # and wait for the real SIGSTOP.
        if siginfo.si_signo == signal.SIGTRAP:
            cont(pid, siginfo.si_signo)
        elif is_stop_signal(siginfo.si_signo):
            return
        else:
            raise OSError('traced process has stopped with an unexpected '
                          'signal {}'.format(siginfo.si_signo))

    pid, status = wait(pid)

    if os.WIFEXITED(status):
        raise OSError('traced process {} has exited with exit code {}'.format(
            pid, os.WEXITSTATUS(status)))

    elif os.WIFSIGNALED(status):
        raise OSError('traced process {} has been killed by '
                      'the {} signal {}'.format(pid, os.WTERMSIG(status)))

    if not os.WIFSTOPPED(status):
        raise OSError('waitpid({}) returned an unexpected status {}'.format(
            pid, hex(status)))

    stopsig = os.WSTOPSIG(status)
    if stopsig != signal.SIGSTOP:
        raise OSError('waitpid({}) returned an unexpected status {}'.format(
            pid, hex(status))) 
開發者ID:pinterest,項目名稱:ptracer,代碼行數:45,代碼來源:ptrace.py

示例15: run

# 需要導入模塊: import os [as 別名]
# 或者: from os import WIFSTOPPED [as 別名]
def run(self):
        """
        self.exit_status = os.waitpid(self.pid, os.WNOHANG | os.WUNTRACED)
        while self.exit_status == (0, 0):
            self.exit_status = os.waitpid(self.pid, os.WNOHANG | os.WUNTRACED)
        """
        self.spawn_target()

        self.finished_starting.set()
        if self.proc_name:
            gone, _ = psutil.wait_procs([self._psutil_proc])
            self.exit_status = gone[0].returncode
        else:
            exit_info = os.waitpid(self.pid, 0)
            self.exit_status = exit_info[1]  # [0] is the pid

        default_reason = "Process died for unknown reason"
        if self.exit_status is not None:
            if os.WCOREDUMP(self.exit_status):
                reason = "Segmentation fault"
            elif os.WIFSTOPPED(self.exit_status):
                reason = "Stopped with signal " + str(os.WTERMSIG(self.exit_status))
            elif os.WIFSIGNALED(self.exit_status):
                reason = "Terminated with signal " + str(os.WTERMSIG(self.exit_status))
            elif os.WIFEXITED(self.exit_status):
                reason = "Exit with code - " + str(os.WEXITSTATUS(self.exit_status))
            else:
                reason = default_reason
        else:
            reason = default_reason

        outdata = None
        errdata = None
        try:
            if self._process is not None:
                outdata, errdata = self._process.communicate(timeout=POPEN_COMMUNICATE_TIMEOUT_FOR_ALREADY_DEAD_TASK)
        except subprocess.TimeoutExpired:
            self.process_monitor.log(
                msg="Expired waiting for process {0} to terminate".format(self._process.pid), level=1
            )

        msg = "[{0}] Crash. Exit code: {1}. Reason - {2}\n".format(
            time.strftime("%I:%M.%S"), self.exit_status if self.exit_status is not None else "<unknown>", reason
        )
        if errdata is not None:
            msg += "STDERR:\n{0}\n".format(errdata.decode("ascii"))
        if outdata is not None:
            msg += "STDOUT:\n{0}\n".format(outdata.decode("ascii"))
        self.process_monitor.last_synopsis = msg 
開發者ID:jtpereyda,項目名稱:boofuzz,代碼行數:51,代碼來源:debugger_thread_simple.py


注:本文中的os.WIFSTOPPED屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。