Python os.WCOREDUMP Examples
The following are 6
code examples of os.WCOREDUMP().
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: session.py From Safejumper-for-Desktop with GNU General Public License v2.0 | 6 votes |
def processEnded(self, reason=None): """ When we are told the process ended, try to notify the other side about how the process ended using the exit-signal or exit-status requests. Also, close the channel. """ if reason is not None: err = reason.value if err.signal is not None: signame = self._getSignalName(err.signal) if (getattr(os, 'WCOREDUMP', None) is not None and os.WCOREDUMP(err.status)): log.msg('exitSignal: %s (core dumped)' % (signame,)) coreDumped = 1 else: log.msg('exitSignal: %s' % (signame,)) coreDumped = 0 self.session.conn.sendRequest(self.session, b'exit-signal', common.NS(networkString(signame[3:])) + chr(coreDumped) + common.NS(b'') + common.NS(b'')) elif err.exitCode is not None: log.msg('exitCode: %r' % (err.exitCode,)) self.session.conn.sendRequest(self.session, b'exit-status', struct.pack('>L', err.exitCode)) self.session.loseConnection()
Example #2
Source File: session.py From learn_python3_spider with MIT License | 5 votes |
def processEnded(self, reason=None): """ When we are told the process ended, try to notify the other side about how the process ended using the exit-signal or exit-status requests. Also, close the channel. """ if reason is not None: err = reason.value if err.signal is not None: signame = self._getSignalName(err.signal) if (getattr(os, 'WCOREDUMP', None) is not None and os.WCOREDUMP(err.status)): log.msg('exitSignal: %s (core dumped)' % (signame,)) coreDumped = 1 else: log.msg('exitSignal: %s' % (signame,)) coreDumped = 0 self.session.conn.sendRequest( self.session, b'exit-signal', common.NS(networkString(signame[3:])) + chr(coreDumped) + common.NS(b'') + common.NS(b'')) elif err.exitCode is not None: log.msg('exitCode: %r' % (err.exitCode,)) self.session.conn.sendRequest(self.session, b'exit-status', struct.pack('>L', err.exitCode)) self.session.loseConnection()
Example #3
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 #4
Source File: session.py From python-for-android with Apache License 2.0 | 5 votes |
def processEnded(self, reason=None): """ When we are told the process ended, try to notify the other side about how the process ended using the exit-signal or exit-status requests. Also, close the channel. """ if reason is not None: err = reason.value if err.signal is not None: signame = self._getSignalName(err.signal) if (getattr(os, 'WCOREDUMP', None) is not None and os.WCOREDUMP(err.status)): log.msg('exitSignal: %s (core dumped)' % (signame,)) coreDumped = 1 else: log.msg('exitSignal: %s' % (signame,)) coreDumped = 0 self.session.conn.sendRequest(self.session, 'exit-signal', common.NS(signame[3:]) + chr(coreDumped) + common.NS('') + common.NS('')) elif err.exitCode is not None: log.msg('exitCode: %r' % (err.exitCode,)) self.session.conn.sendRequest(self.session, 'exit-status', struct.pack('>L', err.exitCode)) self.session.loseConnection() # transport stuff (we are also a transport!)
Example #5
Source File: daemon.py From ryu with Apache License 2.0 | 4 votes |
def _monitor_daemon(daemon_pid): # XXX should log daemon's stderr output at startup time # XXX should use setproctitle module if available last_restart = None while True: retval, status = _waitpid(daemon_pid, 0) if retval < 0: sys.stderr.write("waitpid failed\n") sys.exit(1) elif retval == daemon_pid: status_msg = ("pid %d died, %s" % (daemon_pid, ovs.process.status_msg(status))) if _should_restart(status): if os.WCOREDUMP(status): # Disable further core dumps to save disk space. try: resource.setrlimit(resource.RLIMIT_CORE, (0, 0)) except resource.error: vlog.warn("failed to disable core dumps") # Throttle restarts to no more than once every 10 seconds. if (last_restart is not None and ovs.timeval.msec() < last_restart + 10000): vlog.warn("%s, waiting until 10 seconds since last " "restart" % status_msg) while True: now = ovs.timeval.msec() wakeup = last_restart + 10000 if now > wakeup: break print "sleep %f" % ((wakeup - now) / 1000.0) time.sleep((wakeup - now) / 1000.0) last_restart = ovs.timeval.msec() vlog.err("%s, restarting" % status_msg) daemon_pid = _fork_and_wait_for_startup() if not daemon_pid: break else: vlog.info("%s, exiting" % status_msg) sys.exit(0) # Running in new daemon process.
Example #6
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