Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 5252fc0

Browse files
committedApr 23, 2015
Merge remote-tracking branch 'origin' into 1.8.7
2 parents 859756d + 29316ad commit 5252fc0

File tree

5 files changed

+69
-17
lines changed

5 files changed

+69
-17
lines changed
 

Diff for: ‎kernel/common/kernel.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -551,7 +551,7 @@ def method(name)
551551
if code
552552
Method.new(self, code[1], code[0], name)
553553
else
554-
raise NameError, "undefined method `#{name}' for #{self.inspect}"
554+
raise NameError, "undefined method `#{name}' for class #{self.class}"
555555
end
556556
end
557557

Diff for: ‎vm/environment.cpp

+35
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
#include <sys/stat.h>
5959
#include <sys/types.h>
6060
#include <pwd.h>
61+
#include <dirent.h>
6162

6263
#include "missing/setproctitle.h"
6364

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

541+
static char fsapi_path[MAXPATHLEN];
542+
543+
// Last resort cleanup function if normal cleanup does not occur.
544+
static void remove_fsapi_atexit() {
545+
char path[MAXPATHLEN];
546+
struct dirent* entry;
547+
DIR* dir = opendir(fsapi_path);
548+
549+
if(dir != NULL) {
550+
while((entry = readdir(dir)) != NULL) {
551+
if(entry->d_name[0] == '.') continue;
552+
553+
snprintf(path, MAXPATHLEN, "%s/%s", fsapi_path, entry->d_name);
554+
unlink(path);
555+
}
556+
557+
(void)closedir(dir);
558+
}
559+
560+
rmdir(fsapi_path);
561+
}
562+
540563
void Environment::create_fsapi(STATE) {
564+
strncpy(fsapi_path, shared->fsapi_path.c_str(), MAXPATHLEN);
565+
541566
if(mkdir(shared->fsapi_path.c_str(), shared->config.system_fsapi_access) < 0) {
542567
utilities::logger::error("%s: unable to create FSAPI path", strerror(errno));
543568
}
@@ -554,6 +579,10 @@ namespace rubinius {
554579
}
555580
}
556581

582+
void Environment::atexit() {
583+
remove_fsapi_atexit();
584+
}
585+
557586
void Environment::halt_and_exit(STATE) {
558587
halt(state);
559588
exit(exit_code(state));
@@ -815,6 +844,9 @@ namespace rubinius {
815844

816845
load_platform_conf(runtime);
817846
boot_vm();
847+
848+
::atexit(remove_fsapi_atexit);
849+
818850
start_finalizer(state);
819851

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

827859
start_jit(state);
828860

861+
signal_thread_->print_machine_info(utilities::logger::write);
862+
signal_thread_->print_process_info(utilities::logger::write);
863+
829864
G(rubinius)->set_const(state, "Signature", Integer::from(state, signature_));
830865

831866
G(rubinius)->set_const(state, "RUNTIME_PATH", String::create(state,

Diff for: ‎vm/environment.hpp

+1
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ namespace rubinius {
119119
void halt(STATE);
120120
void halt_and_exit(STATE);
121121
int exit_code(STATE);
122+
void atexit();
122123

123124
void create_fsapi(STATE);
124125
void remove_fsapi(STATE);

Diff for: ‎vm/signal.cpp

+27-16
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,29 @@ namespace rubinius {
9292
InternalThread::stop(state);
9393
}
9494

95+
void SignalThread::print_machine_info(PrintFunction function) {
96+
function("sysname: %s", machine_info.sysname);
97+
function("nodename: %s", machine_info.nodename);
98+
function("release: %s", machine_info.release);
99+
function("version: %s", machine_info.version);
100+
function("machine: %s", machine_info.machine);
101+
}
102+
103+
104+
void SignalThread::print_process_info(PrintFunction function) {
105+
function("user: %s", signal_thread_->shared().username.c_str());
106+
function("pid: %s", signal_thread_->shared().pid.c_str());
107+
function("program name: %s", RBX_PROGRAM_NAME);
108+
function("version: %s", RBX_VERSION);
109+
function("ruby version: %s", RBX_RUBY_VERSION);
110+
function("release date: %s", RBX_RELEASE_DATE);
111+
function("build revision: %s", RBX_BUILD_REV);
112+
function("llvm version: %s", RBX_LLVM_VERSION);
113+
function("jit status: %s",
114+
CBOOL(signal_thread_->shared().env()->state->globals().jit.get()->enabled())
115+
? "enabled" : "disabled");
116+
}
117+
95118
void SignalThread::run(STATE) {
96119
#ifndef RBX_WINDOWS
97120
sigset_t set;
@@ -335,6 +358,8 @@ namespace rubinius {
335358
sleep(timeout);
336359
}
337360

361+
signal_thread_->shared().env()->atexit();
362+
338363
#define RBX_ABORT_CALLSTACK_SIZE 128
339364
void* callstack[RBX_ABORT_CALLSTACK_SIZE];
340365
int i, frames = backtrace(callstack, RBX_ABORT_CALLSTACK_SIZE);
@@ -343,25 +368,11 @@ namespace rubinius {
343368
logger::fatal("The Rubinius process is aborting with signal: %s",
344369
rbx_signal_string(sig));
345370
logger::fatal("--- begin system info ---");
346-
logger::fatal("sysname: %s", machine_info.sysname);
347-
logger::fatal("nodename: %s", machine_info.nodename);
348-
logger::fatal("release: %s", machine_info.release);
349-
logger::fatal("version: %s", machine_info.version);
350-
logger::fatal("machine: %s", machine_info.machine);
371+
signal_thread_->print_machine_info(logger::fatal);
351372
logger::fatal("--- end system info ---");
352373

353374
logger::fatal("--- begin rubinius info ---");
354-
logger::fatal("user: %s", signal_thread_->shared().username.c_str());
355-
logger::fatal("pid: %s", signal_thread_->shared().pid.c_str());
356-
logger::fatal("program name: %s", RBX_PROGRAM_NAME);
357-
logger::fatal("version: %s", RBX_VERSION);
358-
logger::fatal("ruby version: %s", RBX_RUBY_VERSION);
359-
logger::fatal("release date: %s", RBX_RELEASE_DATE);
360-
logger::fatal("build revision: %s", RBX_BUILD_REV);
361-
logger::fatal("llvm version: %s", RBX_LLVM_VERSION);
362-
logger::fatal("jit status: %s",
363-
CBOOL(signal_thread_->shared().env()->state->globals().jit.get()->enabled())
364-
? "enabled" : "disabled");
375+
signal_thread_->print_process_info(logger::fatal);
365376
logger::fatal("--- end rubinius info ---");
366377

367378
logger::fatal("--- begin system backtrace ---");

Diff for: ‎vm/signal.hpp

+5
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,11 @@ namespace rubinius {
5656
void run(STATE);
5757
void stop(STATE);
5858
void wakeup(STATE);
59+
60+
typedef void (*PrintFunction)(const char* message, ...);
61+
62+
void print_machine_info(PrintFunction function);
63+
void print_process_info(PrintFunction function);
5964
};
6065
}
6166

0 commit comments

Comments
 (0)