本文整理汇总了Python中os.WSTOPSIG属性的典型用法代码示例。如果您正苦于以下问题:Python os.WSTOPSIG属性的具体用法?Python os.WSTOPSIG怎么用?Python os.WSTOPSIG使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类os
的用法示例。
在下文中一共展示了os.WSTOPSIG属性的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: platformProcessEvent
# 需要导入模块: import os [as 别名]
# 或者: from os import WSTOPSIG [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?>!"
示例2: _handle_exitstatus
# 需要导入模块: import os [as 别名]
# 或者: from os import WSTOPSIG [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!")
示例3: _handle_exitstatus
# 需要导入模块: import os [as 别名]
# 或者: from os import WSTOPSIG [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!")
示例4: _handle_exitstatus
# 需要导入模块: import os [as 别名]
# 或者: from os import WSTOPSIG [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!")
示例5: __init__
# 需要导入模块: import os [as 别名]
# 或者: from os import WSTOPSIG [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)
示例6: _call_function
# 需要导入模块: import os [as 别名]
# 或者: from os import WSTOPSIG [as 别名]
def _call_function(self, function_address, *args):
if len(args) > 6:
raise Exception('can not pass more than 6 arguments')
registers_backup = self._get_registers()
if mayhem.utilities.architecture_is_32bit(self.__arch__):
registers = {'eip': function_address, 'eax': function_address}
self._set_registers(registers)
backup_sp = self.read_memory(registers_backup['esp'], 4)
self.write_memory(registers_backup['esp'], b'\x00\x00\x00\x00')
for i in range(len(args)):
stack_cursor = registers_backup['esp'] + ((i + 1) * 4)
backup_sp += self.read_memory(stack_cursor, 4)
if args[i] < 0:
self.write_memory(stack_cursor, struct.pack('i', args[i]))
else:
self.write_memory(stack_cursor, struct.pack('I', args[i]))
self._ptrace(PTRACE_CONT)
wait_result = os.waitpid(self.pid, 0)
self.write_memory(registers_backup['esp'], backup_sp)
ending_ip = self._get_registers()['eip']
result = self._get_registers()['eax']
elif mayhem.utilities.architecture_is_64bit(self.__arch__):
registers = {'rip': function_address, 'rax': function_address}
arg_registers = ['rdi', 'rsi', 'rdx', 'rcx', 'r8', 'r9']
for i in range(len(args)):
registers[arg_registers[i]] = args[i]
self._set_registers(registers)
backup_sp = self.read_memory(registers_backup['rsp'], 8)
self.write_memory(registers_backup['rsp'], b'\x00\x00\x00\x00\x00\x00\x00\x00')
self._ptrace(PTRACE_CONT)
wait_result = os.waitpid(self.pid, 0)
self.write_memory(registers_backup['rsp'], backup_sp)
ending_ip = self._get_registers()['rip']
result = self._get_registers()['rax']
self._set_registers(registers_backup)
if os.WSTOPSIG(wait_result[1]) == signal.SIGSEGV and ending_ip != 0:
raise LinuxProcessError('segmentation fault')
return result
示例7: WPTRACEEVENT
# 需要导入模块: import os [as 别名]
# 或者: from os import WSTOPSIG [as 别名]
def WPTRACEEVENT(status):
if os.WIFSTOPPED(status):
stopsig = os.WSTOPSIG(status)
if stopsig == signal.SIGTRAP:
return status >> 16
return 0
示例8: status_msg
# 需要导入模块: import os [as 别名]
# 或者: from os import WSTOPSIG [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
示例9: _convert_exit_status
# 需要导入模块: import os [as 别名]
# 或者: from os import WSTOPSIG [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)
示例10: run
# 需要导入模块: import os [as 别名]
# 或者: from os import WSTOPSIG [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
示例11: _wait_for_trace_stop
# 需要导入模块: import os [as 别名]
# 或者: from os import WSTOPSIG [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)))