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


Python os.WTERMSIG属性代码示例

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


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

示例1: waitfinish

# 需要导入模块: import os [as 别名]
# 或者: from os import WTERMSIG [as 别名]
def waitfinish(self, waiter=os.waitpid):
        pid, systemstatus = waiter(self.pid, 0)
        if systemstatus:
            if os.WIFSIGNALED(systemstatus):
                exitstatus = os.WTERMSIG(systemstatus) + 128
            else:
                exitstatus = os.WEXITSTATUS(systemstatus)
        else:
            exitstatus = 0
        signal = systemstatus & 0x7f
        if not exitstatus and not signal:
            retval = self.RETVAL.open('rb')
            try:
                retval_data = retval.read()
            finally:
                retval.close()
            retval = marshal.loads(retval_data)
        else:
            retval = None
        stdout = self.STDOUT.read()
        stderr = self.STDERR.read()
        self._removetemp()
        return Result(exitstatus, signal, retval, stdout, stderr) 
开发者ID:pytest-dev,项目名称:py,代码行数:25,代码来源:forkedfunc.py

示例2: poll

# 需要导入模块: import os [as 别名]
# 或者: from os import WTERMSIG [as 别名]
def poll(self, flag=os.WNOHANG):
            if self.returncode is None:
                while True:
                    try:
                        pid, sts = os.waitpid(self.pid, flag)
                    except os.error as e:
                        if e.errno == errno.EINTR:
                            continue
                        # Child process not yet created. See #1731717
                        # e.errno == errno.ECHILD == 10
                        return None
                    else:
                        break
                if pid == self.pid:
                    if os.WIFSIGNALED(sts):
                        self.returncode = -os.WTERMSIG(sts)
                    else:
                        assert os.WIFEXITED(sts)
                        self.returncode = os.WEXITSTATUS(sts)
            return self.returncode 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:22,代码来源:forking.py

示例3: platformProcessEvent

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

示例4: signalStatus

# 需要导入模块: import os [as 别名]
# 或者: from os import WTERMSIG [as 别名]
def signalStatus(self, signal):
        """
        Construct a status from the given signal.

        @type signal: L{int} between 0 and 255 inclusive.
        @param signal: The signal number which the status will represent.

        @rtype: L{int}
        @return: A status integer for the given signal.
        """
        # /* If WIFSIGNALED(STATUS), the terminating signal.  */
        # #define __WTERMSIG(status)      ((status) & 0x7f)
        # /* Nonzero if STATUS indicates termination by a signal.  */
        # #define __WIFSIGNALED(status) \
        #    (((signed char) (((status) & 0x7f) + 1) >> 1) > 0)
        status = signal

        # Sanity check
        self.assertTrue(os.WIFSIGNALED(status))
        self.assertEqual(os.WTERMSIG(status), signal)
        self.assertFalse(os.WIFEXITED(status))

        return status 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:25,代码来源:test_mail.py

示例5: poll

# 需要导入模块: import os [as 别名]
# 或者: from os import WTERMSIG [as 别名]
def poll(self, flag=os.WNOHANG):
        if self.returncode is None:
            while True:
                try:
                    pid, sts = os.waitpid(self.pid, flag)
                except OSError as e:
                    # Child process not yet created. See #1731717
                    # e.errno == errno.ECHILD == 10
                    return None
                else:
                    break
            if pid == self.pid:
                if os.WIFSIGNALED(sts):
                    self.returncode = -os.WTERMSIG(sts)
                else:
                    assert os.WIFEXITED(sts)
                    self.returncode = os.WEXITSTATUS(sts)
        return self.returncode 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:20,代码来源:popen_fork.py

示例6: _handle_exitstatus

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

示例7: __callback__

# 需要导入模块: import os [as 别名]
# 或者: from os import WTERMSIG [as 别名]
def __callback__(self, handle, status):
        try:
            pid = self._handles.pop(handle)
            source, callback, args, handle = self._sources.pop(pid)
        except KeyError:
            return

        self._close_process_handle(handle)
        GLib.source_remove(source)

        if hasattr(os, "WIFSIGNALED") and os.WIFSIGNALED(status):
            returncode = -os.WTERMSIG(status)
        elif hasattr(os, "WIFEXITED") and os.WIFEXITED(status):
            returncode = os.WEXITSTATUS(status)

            # FIXME: Hack for adjusting invalid status returned by GLIB
            #    Looks like there is a bug in glib or in pygobject
            if returncode > 128:
                returncode = 128 - returncode
        else:
            returncode = status

        callback(pid, returncode, *args) 
开发者ID:pychess,项目名称:pychess,代码行数:25,代码来源:glib_events.py

示例8: poll

# 需要导入模块: import os [as 别名]
# 或者: from os import WTERMSIG [as 别名]
def poll(self, flag=os.WNOHANG):
        if self.returncode is None:
            while True:
                try:
                    pid, sts = os.waitpid(self.pid, flag)
                except OSError as e:
                    if e.errno == errno.EINTR:
                        continue
                    # Child process not yet created. See #1731717
                    # e.errno == errno.ECHILD == 10
                    return None
                else:
                    break
            if pid == self.pid:
                if os.WIFSIGNALED(sts):
                    self.returncode = -os.WTERMSIG(sts)
                else:
                    assert os.WIFEXITED(sts)
                    self.returncode = os.WEXITSTATUS(sts)
        return self.returncode 
开发者ID:IronLanguages,项目名称:ironpython3,代码行数:22,代码来源:popen_fork.py

示例9: _do_waitpid

# 需要导入模块: import os [as 别名]
# 或者: from os import WTERMSIG [as 别名]
def _do_waitpid(self, loop, expected_pid, callback, args):
            assert expected_pid > 0

            try:
                pid, status = os.waitpid(expected_pid, 0)
            except ChildProcessError:
                # The child process is already reaped
                # (may happen if waitpid() is called elsewhere).
                pid = expected_pid
                returncode = 255
                logger.warning(
                    "Unknown child process pid %d, will report returncode 255", pid
                )
            else:
                if os.WIFSIGNALED(status):
                    returncode = -os.WTERMSIG(status)
                elif os.WIFEXITED(status):
                    returncode = os.WEXITSTATUS(status)
                else:
                    returncode = status

                if loop.get_debug():
                    logger.debug(
                        "process %s exited with returncode %s", expected_pid, returncode
                    )

            if loop.is_closed():
                logger.warning("Loop %r that handles pid %r is closed", loop, pid)
            else:
                loop.call_soon_threadsafe(callback, pid, returncode, *args)

            self._threads.pop(expected_pid)

    # add the watcher to the loop policy 
开发者ID:microsoft,项目名称:botbuilder-python,代码行数:36,代码来源:threading_helper.py

示例10: _handle_exitstatus

# 需要导入模块: import os [as 别名]
# 或者: from os import WTERMSIG [as 别名]
def _handle_exitstatus(self, sts, _WIFSIGNALED=os.WIFSIGNALED,
                _WTERMSIG=os.WTERMSIG, _WIFEXITED=os.WIFEXITED,
                _WEXITSTATUS=os.WEXITSTATUS):
            # 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)
            else:
                # Should never happen
                raise RuntimeError("Unknown child exit status!") 
开发者ID:war-and-code,项目名称:jawfish,代码行数:14,代码来源:subprocess.py

示例11: _set_returncode

# 需要导入模块: import os [as 别名]
# 或者: from os import WTERMSIG [as 别名]
def _set_returncode(self, status):
        if os.WIFSIGNALED(status):
            self.returncode = -os.WTERMSIG(status)
        else:
            assert os.WIFEXITED(status)
            self.returncode = os.WEXITSTATUS(status)
        if self._exit_callback:
            callback = self._exit_callback
            self._exit_callback = None
            callback(self.returncode) 
开发者ID:tao12345666333,项目名称:tornado-zh,代码行数:12,代码来源:process.py

示例12: _on_sigchld

# 需要导入模块: import os [as 别名]
# 或者: from os import WTERMSIG [as 别名]
def _on_sigchld(self, watcher):
            """Callback of libev child watcher. Called when libev event loop
            catches corresponding SIGCHLD signal.
            """
            watcher.stop()
            # Status evaluation copied from `multiprocessing.forking` in Py2.7.
            if os.WIFSIGNALED(watcher.rstatus):
                self._popen.returncode = -os.WTERMSIG(watcher.rstatus)
            else:
                assert os.WIFEXITED(watcher.rstatus)
                self._popen.returncode = os.WEXITSTATUS(watcher.rstatus)
            self._returnevent.set()
            log.debug("SIGCHLD watcher callback for %s invoked. Exitcode "
                      "stored: %s", self.pid, self._popen.returncode) 
开发者ID:jgehrcke,项目名称:gipc,代码行数:16,代码来源:gipc.py

示例13: _handle_exitstatus

# 需要导入模块: import os [as 别名]
# 或者: from os import WTERMSIG [as 别名]
def _handle_exitstatus(self, sts):
            if os.WIFSIGNALED(sts):
                self.returncode = -os.WTERMSIG(sts)
            elif os.WIFEXITED(sts):
                self.returncode = os.WEXITSTATUS(sts)
            else:
                # Should never happen
                raise RuntimeError("Unknown child exit status!")

            _active.remove(self) 
开发者ID:linuxscout,项目名称:mishkal,代码行数:12,代码来源:subprocess24.py

示例14: _handle_exitstatus

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

示例15: _set_returncode

# 需要导入模块: import os [as 别名]
# 或者: from os import WTERMSIG [as 别名]
def _set_returncode(self, status: int) -> None:
        if os.WIFSIGNALED(status):
            self.returncode = -os.WTERMSIG(status)
        else:
            assert os.WIFEXITED(status)
            self.returncode = os.WEXITSTATUS(status)
        # We've taken over wait() duty from the subprocess.Popen
        # object. If we don't inform it of the process's return code,
        # it will log a warning at destruction in python 3.6+.
        self.proc.returncode = self.returncode
        if self._exit_callback:
            callback = self._exit_callback
            self._exit_callback = None
            callback(self.returncode) 
开发者ID:opendevops-cn,项目名称:opendevops,代码行数:16,代码来源:process.py


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