Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin' into 1.8.7
Browse files Browse the repository at this point in the history
brixen committed Apr 23, 2015

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
2 parents 859756d + 29316ad commit 5252fc0
Showing 5 changed files with 69 additions and 17 deletions.
2 changes: 1 addition & 1 deletion kernel/common/kernel.rb
Original file line number Diff line number Diff line change
@@ -551,7 +551,7 @@ def method(name)
if code
Method.new(self, code[1], code[0], name)
else
raise NameError, "undefined method `#{name}' for #{self.inspect}"
raise NameError, "undefined method `#{name}' for class #{self.class}"
end
end

35 changes: 35 additions & 0 deletions vm/environment.cpp
Original file line number Diff line number Diff line change
@@ -58,6 +58,7 @@
#include <sys/stat.h>
#include <sys/types.h>
#include <pwd.h>
#include <dirent.h>

#include "missing/setproctitle.h"

@@ -537,7 +538,31 @@ namespace rubinius {
halt_lock_.init();
}

static char fsapi_path[MAXPATHLEN];

// Last resort cleanup function if normal cleanup does not occur.
static void remove_fsapi_atexit() {
char path[MAXPATHLEN];
struct dirent* entry;
DIR* dir = opendir(fsapi_path);

if(dir != NULL) {
while((entry = readdir(dir)) != NULL) {
if(entry->d_name[0] == '.') continue;

snprintf(path, MAXPATHLEN, "%s/%s", fsapi_path, entry->d_name);
unlink(path);
}

(void)closedir(dir);
}

rmdir(fsapi_path);
}

void Environment::create_fsapi(STATE) {
strncpy(fsapi_path, shared->fsapi_path.c_str(), MAXPATHLEN);

if(mkdir(shared->fsapi_path.c_str(), shared->config.system_fsapi_access) < 0) {
utilities::logger::error("%s: unable to create FSAPI path", strerror(errno));
}
@@ -554,6 +579,10 @@ namespace rubinius {
}
}

void Environment::atexit() {
remove_fsapi_atexit();
}

void Environment::halt_and_exit(STATE) {
halt(state);
exit(exit_code(state));
@@ -815,6 +844,9 @@ namespace rubinius {

load_platform_conf(runtime);
boot_vm();

::atexit(remove_fsapi_atexit);

start_finalizer(state);

load_argv(argc_, argv_);
@@ -826,6 +858,9 @@ namespace rubinius {

start_jit(state);

signal_thread_->print_machine_info(utilities::logger::write);
signal_thread_->print_process_info(utilities::logger::write);

G(rubinius)->set_const(state, "Signature", Integer::from(state, signature_));

G(rubinius)->set_const(state, "RUNTIME_PATH", String::create(state,
1 change: 1 addition & 0 deletions vm/environment.hpp
Original file line number Diff line number Diff line change
@@ -119,6 +119,7 @@ namespace rubinius {
void halt(STATE);
void halt_and_exit(STATE);
int exit_code(STATE);
void atexit();

void create_fsapi(STATE);
void remove_fsapi(STATE);
43 changes: 27 additions & 16 deletions vm/signal.cpp
Original file line number Diff line number Diff line change
@@ -92,6 +92,29 @@ namespace rubinius {
InternalThread::stop(state);
}

void SignalThread::print_machine_info(PrintFunction function) {
function("sysname: %s", machine_info.sysname);
function("nodename: %s", machine_info.nodename);
function("release: %s", machine_info.release);
function("version: %s", machine_info.version);
function("machine: %s", machine_info.machine);
}


void SignalThread::print_process_info(PrintFunction function) {
function("user: %s", signal_thread_->shared().username.c_str());
function("pid: %s", signal_thread_->shared().pid.c_str());
function("program name: %s", RBX_PROGRAM_NAME);
function("version: %s", RBX_VERSION);
function("ruby version: %s", RBX_RUBY_VERSION);
function("release date: %s", RBX_RELEASE_DATE);
function("build revision: %s", RBX_BUILD_REV);
function("llvm version: %s", RBX_LLVM_VERSION);
function("jit status: %s",
CBOOL(signal_thread_->shared().env()->state->globals().jit.get()->enabled())
? "enabled" : "disabled");
}

void SignalThread::run(STATE) {
#ifndef RBX_WINDOWS
sigset_t set;
@@ -335,6 +358,8 @@ namespace rubinius {
sleep(timeout);
}

signal_thread_->shared().env()->atexit();

#define RBX_ABORT_CALLSTACK_SIZE 128
void* callstack[RBX_ABORT_CALLSTACK_SIZE];
int i, frames = backtrace(callstack, RBX_ABORT_CALLSTACK_SIZE);
@@ -343,25 +368,11 @@ namespace rubinius {
logger::fatal("The Rubinius process is aborting with signal: %s",
rbx_signal_string(sig));
logger::fatal("--- begin system info ---");
logger::fatal("sysname: %s", machine_info.sysname);
logger::fatal("nodename: %s", machine_info.nodename);
logger::fatal("release: %s", machine_info.release);
logger::fatal("version: %s", machine_info.version);
logger::fatal("machine: %s", machine_info.machine);
signal_thread_->print_machine_info(logger::fatal);
logger::fatal("--- end system info ---");

logger::fatal("--- begin rubinius info ---");
logger::fatal("user: %s", signal_thread_->shared().username.c_str());
logger::fatal("pid: %s", signal_thread_->shared().pid.c_str());
logger::fatal("program name: %s", RBX_PROGRAM_NAME);
logger::fatal("version: %s", RBX_VERSION);
logger::fatal("ruby version: %s", RBX_RUBY_VERSION);
logger::fatal("release date: %s", RBX_RELEASE_DATE);
logger::fatal("build revision: %s", RBX_BUILD_REV);
logger::fatal("llvm version: %s", RBX_LLVM_VERSION);
logger::fatal("jit status: %s",
CBOOL(signal_thread_->shared().env()->state->globals().jit.get()->enabled())
? "enabled" : "disabled");
signal_thread_->print_process_info(logger::fatal);
logger::fatal("--- end rubinius info ---");

logger::fatal("--- begin system backtrace ---");
5 changes: 5 additions & 0 deletions vm/signal.hpp
Original file line number Diff line number Diff line change
@@ -56,6 +56,11 @@ namespace rubinius {
void run(STATE);
void stop(STATE);
void wakeup(STATE);

typedef void (*PrintFunction)(const char* message, ...);

void print_machine_info(PrintFunction function);
void print_process_info(PrintFunction function);
};
}

0 comments on commit 5252fc0

Please sign in to comment.