Python os.WIFSTOPPED Examples
The following are 23
code examples of os.WIFSTOPPED().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
os
, or try the search function
.
Example #1
Source File: subprocess.py From Imogen with MIT License | 6 votes |
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!")
Example #2
Source File: subprocess32.py From twitter-stock-recommendation with MIT License | 6 votes |
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!")
Example #3
Source File: subprocess.py From android_universal with MIT License | 6 votes |
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!")
Example #4
Source File: subprocess.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 6 votes |
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!")
Example #5
Source File: linux.py From nightmare with GNU General Public License v2.0 | 6 votes |
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)
Example #6
Source File: posix.py From nightmare with GNU General Public License v2.0 | 6 votes |
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?>!"
Example #7
Source File: ptyprocess.py From pipenv-sublime with MIT License | 5 votes |
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
Example #8
Source File: pexpect.py From lpts with GNU General Public License v2.0 | 5 votes |
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
Example #9
Source File: subprocess.py From unity-python with MIT License | 5 votes |
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!")
Example #10
Source File: ptyprocess.py From jarvis with GNU General Public License v2.0 | 5 votes |
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
Example #11
Source File: fork.py From mitogen with BSD 3-Clause "New" or "Revised" License | 5 votes |
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)
Example #12
Source File: process.py From ryu with Apache License 2.0 | 5 votes |
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
Example #13
Source File: _pexpect.py From Computable with MIT License | 5 votes |
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
Example #14
Source File: __init__.py From camr with GNU General Public License v2.0 | 5 votes |
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
Example #15
Source File: subprocess.py From ironpython2 with Apache License 2.0 | 5 votes |
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!")
Example #16
Source File: ptyprocess.py From sublime_debugger with MIT License | 5 votes |
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
Example #17
Source File: pexpect.py From smod-1 with GNU General Public License v2.0 | 5 votes |
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
Example #18
Source File: _defs_linux.py From ptracer with Apache License 2.0 | 5 votes |
def WPTRACEEVENT(status): if os.WIFSTOPPED(status): stopsig = os.WSTOPSIG(status) if stopsig == signal.SIGTRAP: return status >> 16 return 0
Example #19
Source File: exitstatus.py From pycopia with Apache License 2.0 | 5 votes |
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)
Example #20
Source File: ptyprocess.py From pipenv with MIT License | 5 votes |
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
Example #21
Source File: AflThread.py From afl-utils with Apache License 2.0 | 4 votes |
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
Example #22
Source File: ptrace.py From ptracer with Apache License 2.0 | 4 votes |
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)))
Example #23
Source File: debugger_thread_simple.py From boofuzz with GNU General Public License v2.0 | 4 votes |
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