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


Python signal.SIGFPE属性代码示例

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


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

示例1: test_issue9324

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

示例2: _default_handler

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

示例3: __interceptSignals

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

示例4: __signalHandler

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

示例5: test_issue9324

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

示例6: test_module_constants

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

示例7: signal_to_string

# 需要导入模块: import signal [as 别名]
# 或者: from signal import SIGFPE [as 别名]
def signal_to_string(self, signalNumber):
        if signalNumber < 0:
            signalNumber = signalNumber * -1

        if signalNumber == signal.SIGINT:
            return "SIGINT - Interrupt (Ctrl+C)"
        elif signalNumber == signal.SIGKILL:
            return "SIGKILL - Killed"
        elif signalNumber == signal.SIGTERM:
            return "SIGTERM - Terminated"
        elif signalNumber == signal.SIGSEGV:
            return "SIGSEGV - Segmentation fault"
        elif signalNumber == signal.SIGHUP:
            return "SIGHUP - Hang up"
        elif signalNumber == signal.SIGBUS:
            return "SIGBUS - Bus error"
        elif signalNumber == signal.SIGILL:
            return "SIGILL - Illegal instruction"
        elif signalNumber == signal.SIGFPE:
            return "SIGFPE - Floating point exception"
        elif signalNumber == signal.SIGPIPE:
            return "SIGPIPE - Broken pipe (write to pipe with no readers)"
        elif signalNumber == signal.SIGABRT:
            return "SIGABRT - Called abort()"
        elif signalNumber == signal.SIGXFSZ:
            return "SIGXFSZ - Process created files that were too big."
        elif signalNumber == signal.SIGXCPU:
            return "SIGXCPU - Process used too much CPU time."
        else:
            return "Unknown signal #" + str(signalNumber) 
开发者ID:skuhl,项目名称:autograder,代码行数:32,代码来源:autograder.py

示例8: GetMonitorData

# 需要导入模块: import signal [as 别名]
# 或者: from signal import SIGFPE [as 别名]
def GetMonitorData(self):
        time.sleep(self.lookout_time)
        sytem_crash_report = self.get_crash_report(self.system_report_path)
        bucket = {}

        if not len(self.crash_trace):
            if self.process.returncode < 0:
                crashSignals = [
                    # POSIX.1-1990 signals
                    signal.SIGILL,
                    signal.SIGABRT,
                    signal.SIGFPE,
                    signal.SIGSEGV,
                    # SUSv2 / POSIX.1-2001 signals
                    signal.SIGBUS,
                    signal.SIGSYS,
                    signal.SIGTRAP,
            ]
            for crashSignal in crashSignals:
                if process.returncode == -crashSignal:
                    bucket["auxdat.txt"] = "Process exited with signal: %d" % -process.returncode
        else:
            bucket["auxdat.txt"] = "".join(self.crash_trace)

        if sytem_crash_report:
            bucket["system_crash_report.txt"] = sytem_crash_report

        if self.console_log:
            bucket["stdout.txt"] = "".join(self.console_log[-1000:])

        if self.failure:
            meta = {
                "environ": os.environ.data,
                "command": self.arguments
            }
            bucket["meta.txt"] = json.dumps(dict(meta))
            bucket["Bucket"] = os.path.basename(self.command)
            return bucket 
开发者ID:MozillaSecurity,项目名称:peach,代码行数:40,代码来源:process.py

示例9: explain_signal

# 需要导入模块: import signal [as 别名]
# 或者: from signal import SIGFPE [as 别名]
def explain_signal(signal_number):
	if signal_number == signal.SIGINT:
		return "Execution was interrupted"
	elif signal_number == signal.SIGFPE:
		return 'Execution stopped by an arithmetic error.\nOften this is caused by division (or %) by zero.'
	elif signal_number == signal.SIGXCPU:
		return "Execution stopped by a CPU time limit."
	elif signal_number == signal.SIGXFSZ:
		return "Execution stopped because too much data written."
	else:
		return "Execution terminated by signal %s" % signal_number 
开发者ID:COMP1511UNSW,项目名称:dcc,代码行数:13,代码来源:drive_gdb.py

示例10: _analyze

# 需要导入模块: import signal [as 别名]
# 或者: from signal import SIGFPE [as 别名]
def _analyze(self):
        if self.signum == SIGSEGV:
            self.memoryFault()
        elif self.signum == SIGFPE:
            self.mathError()
        elif self.signum == SIGCHLD:
            self.childExit()
        elif self.signum == SIGABRT:
            self.error = Abort()
        return self.error 
开发者ID:tuwid,项目名称:darkc0de-old-stuff,代码行数:12,代码来源:ptrace_signal.py

示例11: _StartProcess

# 需要导入模块: import signal [as 别名]
# 或者: from signal import SIGFPE [as 别名]
def _StartProcess(self):
        MonitorDebug(self._name, "_StartProcess")
        self.failure = False
        self.sanlog = []
        self.stderr = []
        self.stdout = []

        print("Command: {}".format(self.arguments))
        self.process = Popen(self.arguments, stderr=PIPE, stdout=PIPE,
                             env=os.environ, bufsize=1, close_fds=isPosix())

        # Todo: Add timeout= for GUI applications.
        stdout, stderr = self.process.communicate()

        if stderr.find("ERROR: AddressSanitizer: ") != -1:
            if stderr.find("AddressSanitizer failed to allocate") == -1:
                self.failure = True
                self.sanlog = re.findall(self.asan_regex, stderr, re.DOTALL)[0]
                self.stdout = stdout
                self.stderr = stderr
        else:
            if self.process.returncode < 0:
                crashSignals = [
                    # POSIX.1-1990 signals
                    signal.SIGILL,
                    signal.SIGABRT,
                    signal.SIGFPE,
                    signal.SIGSEGV,
                    # SUSv2 / POSIX.1-2001 signals
                    signal.SIGBUS,
                    signal.SIGSYS,
                    signal.SIGTRAP,
            ]
            for crashSignal in crashSignals:
                if process.returncode == -crashSignal:
                    self.failure = True
                    self.sanlog = "Process exited with signal: %d" % -process.returncode
                    self.stdout = stdout
                    self.stderr = stderr

        if self.failure:
            self._StopProcess() 
开发者ID:MozillaSecurity,项目名称:peach,代码行数:44,代码来源:process.py


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