Python os.WTERMSIG Examples
The following are 30
code examples of os.WTERMSIG().
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: popen_fork.py From ironpython3 with Apache License 2.0 | 6 votes |
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
Example #2
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 #3
Source File: forkedfunc.py From scylla with Apache License 2.0 | 6 votes |
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)
Example #4
Source File: glib_events.py From pychess with GNU General Public License v3.0 | 6 votes |
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)
Example #5
Source File: forking.py From oss-ftp with MIT License | 6 votes |
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
Example #6
Source File: forking.py From ironpython2 with Apache License 2.0 | 6 votes |
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
Example #7
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 #8
Source File: forking.py From BinderFilter with MIT License | 6 votes |
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
Example #9
Source File: test_mail.py From Safejumper-for-Desktop with GNU General Public License v2.0 | 6 votes |
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
Example #10
Source File: forkedfunc.py From python-netsurv with MIT License | 6 votes |
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)
Example #11
Source File: forkedfunc.py From python-netsurv with MIT License | 6 votes |
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)
Example #12
Source File: popen_fork.py From Fluid-Designer with GNU General Public License v3.0 | 6 votes |
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
Example #13
Source File: forkedfunc.py From py with MIT License | 6 votes |
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)
Example #14
Source File: subprocess.py From Fluid-Designer with GNU General Public License v3.0 | 5 votes |
def _handle_exitstatus(self, sts, _WIFSIGNALED=os.WIFSIGNALED, _WTERMSIG=os.WTERMSIG, _WIFEXITED=os.WIFEXITED, _WEXITSTATUS=os.WEXITSTATUS): """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) else: # Should never happen raise SubprocessError("Unknown child exit status!")
Example #15
Source File: subprocess_hack.py From advanced-launcher with GNU General Public License v2.0 | 5 votes |
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)
Example #16
Source File: megatest.py From magnitude with MIT License | 5 votes |
def run(cmd): status=os.system(cmd) if os.WIFEXITED(status): code=os.WEXITSTATUS(status) if code==0: return raise Exception("Exited with code "+`code`+": "+cmd) raise Exception("Failed with signal "+`os.WTERMSIG(status)`+": "+cmd)
Example #17
Source File: unix_events.py From Fluid-Designer with GNU General Public License v3.0 | 5 votes |
def _compute_returncode(self, status): if os.WIFSIGNALED(status): # The child process died because of a signal. return -os.WTERMSIG(status) elif os.WIFEXITED(status): # The child process exited (e.g sys.exit()). return os.WEXITSTATUS(status) else: # The child exited, but we don't understand its status. # This shouldn't happen, but if it does, let's just # return that status; perhaps that helps debug it. return status
Example #18
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 #19
Source File: process.py From teleport with Apache License 2.0 | 5 votes |
def _set_returncode(self, status): 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)
Example #20
Source File: test_process.py From learn_python3_spider with MIT License | 5 votes |
def test_signalKILL(self): """ Sending the SIGKILL signal to a running process interrupts it, and C{processEnded} is called with a L{error.ProcessTerminated} instance with the C{exitCode} set to L{None} and the C{signal} attribute set to C{signal.SIGKILL}. C{os.WTERMSIG} can also be used on the C{status} attribute to extract the signal value. """ return self._testSignal('KILL')
Example #21
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 #22
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 #23
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 #24
Source File: subprocess.py From pmatic with GNU General Public License v2.0 | 5 votes |
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!")
Example #25
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 #26
Source File: systemctl3.py From vanilla-docker with MIT License | 5 votes |
def subprocess_testpid(pid): testpid = collections.namedtuple("testpid", ["pid", "returncode", "signal" ]) run_pid, run_stat = os.waitpid(pid, os.WNOHANG) if run_pid: return testpid(run_pid, os.WEXITSTATUS(run_stat), os.WTERMSIG(run_stat)) else: return testpid(pid, None, 0)
Example #27
Source File: systemctl3.py From vanilla-docker with MIT License | 5 votes |
def subprocess_waitpid(pid): waitpid = collections.namedtuple("waitpid", ["pid", "returncode", "signal" ]) run_pid, run_stat = os.waitpid(pid, 0) return waitpid(run_pid, os.WEXITSTATUS(run_stat), os.WTERMSIG(run_stat))
Example #28
Source File: process.py From teleport with Apache License 2.0 | 5 votes |
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)
Example #29
Source File: process.py From teleport with Apache License 2.0 | 5 votes |
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)
Example #30
Source File: subprocess.py From satori with Apache License 2.0 | 5 votes |
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!")