Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: rubinius/rubinius
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 76701eba77a5
Choose a base ref
...
head repository: rubinius/rubinius
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 29316ad7f29c
Choose a head ref
  • 2 commits
  • 4 files changed
  • 1 contributor

Commits on Apr 23, 2015

  1. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    0a24c5b View commit details
  2. Copy the full SHA
    29316ad View commit details
Showing with 68 additions and 16 deletions.
  1. +35 −0 vm/environment.cpp
  2. +1 −0 vm/environment.hpp
  3. +27 −16 vm/signal.cpp
  4. +5 −0 vm/signal.hpp
35 changes: 35 additions & 0 deletions vm/environment.cpp
Original file line number Diff line number Diff line change
@@ -59,6 +59,7 @@
#include <sys/stat.h>
#include <sys/types.h>
#include <pwd.h>
#include <dirent.h>

#include "missing/setproctitle.h"

@@ -543,7 +544,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));
}
@@ -560,6 +585,10 @@ namespace rubinius {
}
}

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

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

load_platform_conf(runtime);
boot_vm();

::atexit(remove_fsapi_atexit);

start_finalizer(state);

load_argv(argc_, argv_);
@@ -832,6 +864,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);
};
}