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


Python signal.SIGSEGV属性代码示例

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


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

示例1: test_run_async_exit_code

# 需要导入模块: import signal [as 别名]
# 或者: from signal import SIGSEGV [as 别名]
def test_run_async_exit_code(self):

        def run_with_exit_code_0(process_idx):
            sys.exit(0)

        def run_with_exit_code_11(process_idx):
            os.kill(os.getpid(), signal.SIGSEGV)

        with warnings.catch_warnings(record=True) as ws:
            async_.run_async(4, run_with_exit_code_0)
            # There should be no AbnormalExitWarning
            self.assertEqual(
                sum(1 if issubclass(
                    w.category, async_.AbnormalExitWarning) else 0
                    for w in ws), 0)

        with warnings.catch_warnings(record=True) as ws:
            async_.run_async(4, run_with_exit_code_11)
            # There should be 4 AbnormalExitWarning
            self.assertEqual(
                sum(1 if issubclass(
                    w.category, async_.AbnormalExitWarning) else 0
                    for w in ws), 4) 
开发者ID:chainer,项目名称:chainerrl,代码行数:25,代码来源:test_async.py

示例2: test_debug_crash_segfault

# 需要导入模块: import signal [as 别名]
# 或者: from signal import SIGSEGV [as 别名]
def test_debug_crash_segfault():
    """Verify that debug_crash crashes as intended."""
    caught = False

    def _handler(num, frame):
        """Temporary handler for segfault."""
        nonlocal caught
        caught = num == signal.SIGSEGV

    with _trapped_segv(_handler):
        # since we handle the segfault, execution will continue and run into
        # the "Segfault failed (wat.)" Exception
        with pytest.raises(Exception, match="Segfault failed"):
            misccommands.debug_crash(typ='segfault')
        time.sleep(0.001)
    assert caught 
开发者ID:qutebrowser,项目名称:qutebrowser,代码行数:18,代码来源:test_misccommands.py

示例3: _SigSegvHandler

# 需要导入模块: import signal [as 别名]
# 或者: from signal import SIGSEGV [as 别名]
def _SigSegvHandler(self, signal_number, stack_frame):
    """Signal handler for the SIGSEGV signal.

    Args:
      signal_number (int): numeric representation of the signal.
      stack_frame (frame): current stack frame or None.
    """
    self._OnCriticalError()

    # Note that the original SIGSEGV handler can be 0.
    if self._original_sigsegv_handler is not None:
      # Let the original SIGSEGV handler take over.
      signal.signal(signal.SIGSEGV, self._original_sigsegv_handler)
      os.kill(self._pid, signal.SIGSEGV)

  # pylint: disable=unused-argument 
开发者ID:log2timeline,项目名称:plaso,代码行数:18,代码来源:base_process.py

示例4: test_issue9324

# 需要导入模块: import signal [as 别名]
# 或者: from signal import SIGSEGV [as 别名]
def test_issue9324(self):
        # Updated for issue #10003, adding SIGBREAK
        handler = lambda x, y: None
        checked = set()
        for sig in (signal.SIGABRT, signal.SIGBREAK, signal.SIGFPE,
                    signal.SIGILL, signal.SIGINT, signal.SIGSEGV,
                    signal.SIGTERM):
            # Set and then reset a handler for signals that work on windows.
            # Issue #18396, only for signals without a C-level handler.
            if signal.getsignal(sig) is not None:
                signal.signal(sig, signal.signal(sig, handler))
                checked.add(sig)
        # Issue #18396: Ensure the above loop at least tested *something*
        self.assertTrue(checked)

        with self.assertRaises(ValueError):
            signal.signal(-1, handler)

        with self.assertRaises(ValueError):
            signal.signal(7, handler) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:22,代码来源:test_signal.py

示例5: _default_handler

# 需要导入模块: import signal [as 别名]
# 或者: from signal import SIGSEGV [as 别名]
def _default_handler(signum, *args):
        ''' The default signal handler. Don't register with built-in
        signal.signal! This needs to be used on the subprocess await
        death workaround.
        '''
        # All valid cpython windows signals
        sigs = {
            signal.SIGABRT: SIGABRT,
            # signal.SIGFPE: 'fpe', # Don't catch this
            # signal.SIGSEGV: 'segv', # Don't catch this
            # signal.SIGILL: 'illegal', # Don't catch this
            signal.SIGINT: SIGINT,
            signal.SIGTERM: SIGTERM,
            # Note that signal.CTRL_C_EVENT and signal.CTRL_BREAK_EVENT are
            # converted to SIGINT in _await_signal
        }
        
        try:
            exc = sigs[signum]
        except KeyError:
            exc = DaemonikerSignal
            
        _sketch_raise_in_main(exc) 
开发者ID:Muterra,项目名称:py_daemoniker,代码行数:25,代码来源:_signals_windows.py

示例6: sig2exc

# 需要导入模块: import signal [as 别名]
# 或者: from signal import SIGSEGV [as 别名]
def sig2exc(sig, frm):
            """ signal handler """

            error = PilotErrors()
            runJob.setGlobalPilotErrorDiag("!!FAILED!!3000!! SIGTERM Signal %s is caught in child pid=%d!\n" % (sig, os.getpid()))
            tolog(runJob.getGlobalPilotErrorDiag())
            if sig == signal.SIGTERM:
                runJob.setGlobalErrorCode(error.ERR_SIGTERM)
            elif sig == signal.SIGQUIT:
                runJob.setGlobalErrorCode(error.ERR_SIGQUIT)
            elif sig == signal.SIGSEGV:
                runJob.setGlobalErrorCode(error.ERR_SIGSEGV)
            elif sig == signal.SIGXCPU:
                runJob.setGlobalErrorCode(error.ERR_SIGXCPU)
            elif sig == signal.SIGBUS:
                runJob.setGlobalErrorCode(error.ERR_SIGBUS)
            elif sig == signal.SIGUSR1:
                runJob.setGlobalErrorCode(error.ERR_SIGUSR1)
            else:
                runJob.setGlobalErrorCode(error.ERR_KILLSIGNAL)
            runJob.setFailureCode(runJob.getGlobalErrorCode)
            # print to stderr
            print >> sys.stderr, runJob.getGlobalPilotErrorDiag()
            raise SystemError(sig) 
开发者ID:PanDAWMS,项目名称:pilot,代码行数:26,代码来源:RunJobEdison.py

示例7: sig2exc

# 需要导入模块: import signal [as 别名]
# 或者: from signal import SIGSEGV [as 别名]
def sig2exc(sig, frm):
            """ signal handler """

            error = PilotErrors()
            runJob.setGlobalPilotErrorDiag("!!FAILED!!3000!! SIGTERM Signal %s is caught in child pid=%d!\n" % (sig, os.getpid()))
            tolog(runJob.getGlobalPilotErrorDiag())
            if sig == signal.SIGTERM:
                runJob.setGlobalErrorCode(error.ERR_SIGTERM)
            elif sig == signal.SIGQUIT:
                runJob.setGlobalErrorCode(error.ERR_SIGQUIT)
            elif sig == signal.SIGSEGV:
                runJob.setGlobalErrorCode(error.ERR_SIGSEGV)
            elif sig == signal.SIGXCPU:
                runJob.setGlobalErrorCode(error.ERR_SIGXCPU)
            elif sig == signal.SIGBUS:
                runJob.setGlobalErrorCode(error.ERR_SIGBUS)
            elif sig == signal.SIGUSR1:
                runJob.setGlobalErrorCode(error.ERR_SIGUSR1)
            else:
                runJob.setGlobalErrorCode(error.ERR_KILLSIGNAL)
            runJob.setFailureCode(runJob.getGlobalErrorCode())
            # print to stderr
            print >> sys.stderr, runJob.getGlobalPilotErrorDiag()
            raise SystemError(sig) 
开发者ID:PanDAWMS,项目名称:pilot,代码行数:26,代码来源:RunJob.py

示例8: run

# 需要导入模块: import signal [as 别名]
# 或者: from signal import SIGSEGV [as 别名]
def run(self):
        if os.path.isfile(self.__executable):
            result = subprocess.run(self.__executable, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)

            output = result.stdout.decode('utf-8')
            print(output)

            exit_code = result.returncode
            if exit_code == EExitCode.success:
                exit(exit_code)
            elif exit_code == -signal.SIGSEGV:
                logging.error("Segmentation fault signal is received during unit-testing process.")
                exit(exit_code)

            for _ in range(self.__attempts):
                exit_code, output = self.__rerun(output)
                if exit_code == EExitCode.success:
                    exit(exit_code)
                elif exit_code == EExitCode.failure_tests_not_found:
                    logging.error("There is nothing to rerun - failure tests are not found despite failure code '"
                                  + str(result.returncode) + "'.")
                    exit(exit_code)
        else:
            logging.error("Impossible to find executable file '%s'." % self.__executable)
            exit(EExitCode.executable_not_found) 
开发者ID:annoviko,项目名称:pyclustering,代码行数:27,代码来源:ut-runner.py

示例9: __init__

# 需要导入模块: import signal [as 别名]
# 或者: from signal import SIGSEGV [as 别名]
def __init__(self, _args=None) -> None:
        super().__init__()
        self.windowTitleChanged.connect(self.on_windowTitleChanged)
        with open_in_directory_of(__file__, "mainwindow.ui") as file:
            uic.loadUi(file, self, package="application.ui")

        for sig in (signal.SIGABRT, signal.SIGINT, signal.SIGSEGV, signal.SIGTERM):
            signal.signal(sig, lambda signal, frame: self.handle_signal(signal))

        # catch the interpreter every now and then to be able to catch signals
        self.idle_timer = QtCore.QTimer()
        self.idle_timer.timeout.connect(lambda: None)
        self.idle_timer.start(200)

        log().info("app dir: %r", application_root_dir())

        self.setMouseTracking(True) 
开发者ID:frans-fuerst,项目名称:track,代码行数:19,代码来源:mainwindow.py

示例10: _trapped_segv

# 需要导入模块: import signal [as 别名]
# 或者: from signal import SIGSEGV [as 别名]
def _trapped_segv(handler):
    """Temporarily install given signal handler for SIGSEGV."""
    old_handler = signal.signal(signal.SIGSEGV, handler)
    yield
    if old_handler is not None:
        signal.signal(signal.SIGSEGV, old_handler) 
开发者ID:qutebrowser,项目名称:qutebrowser,代码行数:8,代码来源:test_misccommands.py

示例11: debug_crash

# 需要导入模块: import signal [as 别名]
# 或者: from signal import SIGSEGV [as 别名]
def debug_crash(typ: str = 'exception') -> None:
    """Crash for debugging purposes.

    Args:
        typ: either 'exception' or 'segfault'.
    """
    if typ == 'segfault':
        os.kill(os.getpid(), signal.SIGSEGV)
        raise Exception("Segfault failed (wat.)")
    raise Exception("Forced crash") 
开发者ID:qutebrowser,项目名称:qutebrowser,代码行数:12,代码来源:misccommands.py

示例12: __interceptSignals

# 需要导入模块: import signal [as 别名]
# 或者: from signal import SIGSEGV [as 别名]
def __interceptSignals(self):
        """Intercepts common signals"""
        for signum in [signal.SIGABRT,          # abnormal termination
                       signal.SIGFPE,           # floating point exception
                       signal.SIGILL,           # illegal instruction
                       signal.SIGSEGV]:         # segmentation violation
            signal.signal(signum, self.__signalHandler) 
开发者ID:SergeySatskiy,项目名称:codimension,代码行数:9,代码来源:clientbase_cdm_dbg.py

示例13: __signalHandler

# 需要导入模块: import signal [as 别名]
# 或者: from signal import SIGSEGV [as 别名]
def __signalHandler(self, signalNumber, stackFrame):
        """Handles signals"""
        if signalNumber == signal.SIGABRT:
            message = "Abnormal Termination"
        elif signalNumber == signal.SIGFPE:
            message = "Floating Point Exception"
        elif signalNumber == signal.SIGILL:
            message = "Illegal Instruction"
        elif signalNumber == signal.SIGSEGV:
            message = "Segmentation Violation"
        else:
            message = "Unknown Signal '{0}'".format(signalNumber)

        filename = self.absPath(stackFrame.f_code.co_filename)

        linenr = stackFrame.f_lineno
        ffunc = stackFrame.f_code.co_name

        if ffunc == '?':
            ffunc = ''

        if ffunc and not ffunc.startswith('<'):
            argInfo = getArgValues(stackFrame)
            try:
                fargs = formatArgValues(
                    argInfo.args, argInfo.varargs,
                    argInfo.keywords, argInfo.locals)
            except Exception:
                fargs = ''
        else:
            fargs = ''

        sendJSONCommand(self.socket, METHOD_SIGNAL,
                        self.procuuid,
                        {'message': message, 'filename': filename,
                         'linenumber': linenr, 'function': ffunc,
                         'arguments': fargs}) 
开发者ID:SergeySatskiy,项目名称:codimension,代码行数:39,代码来源:clientbase_cdm_dbg.py

示例14: test_issue9324

# 需要导入模块: import signal [as 别名]
# 或者: from signal import SIGSEGV [as 别名]
def test_issue9324(self):
        # Updated for issue #10003, adding SIGBREAK
        handler = lambda x, y: None
        for sig in (signal.SIGABRT, signal.SIGBREAK, signal.SIGFPE,
                    signal.SIGILL, signal.SIGINT, signal.SIGSEGV,
                    signal.SIGTERM):
            # Set and then reset a handler for signals that work on windows
            signal.signal(sig, signal.signal(sig, handler))

        with self.assertRaises(ValueError):
            signal.signal(-1, handler)

        with self.assertRaises(ValueError):
            signal.signal(7, handler) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:16,代码来源:test_signal.py

示例15: test_module_constants

# 需要导入模块: import signal [as 别名]
# 或者: from signal import SIGSEGV [as 别名]
def test_module_constants(self):
        self.assertEqual(signal.NSIG, 23)
        self.assertEqual(signal.SIGABRT, 22)
        self.assertEqual(signal.SIGBREAK, 21)
        self.assertEqual(signal.SIGFPE, 8)
        self.assertEqual(signal.SIGILL, 4)
        self.assertEqual(signal.SIGINT, 2)
        self.assertEqual(signal.SIGSEGV, 11)
        self.assertEqual(signal.SIGTERM, 15)
        self.assertEqual(signal.SIG_DFL, 0)
        self.assertEqual(signal.SIG_IGN, 1) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:13,代码来源:test_signal.py


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