Skip to content

Commit

Permalink
Fixed setting Console in/output after fork().
Browse files Browse the repository at this point in the history
  • Loading branch information
brixen committed Apr 4, 2015
1 parent cfccf9d commit b580cd6
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 12 deletions.
22 changes: 11 additions & 11 deletions vm/environment.cpp
Expand Up @@ -201,9 +201,9 @@ namespace rubinius {
} else if(!config.system_log.value.compare("console")) {
utilities::logger::open(utilities::logger::eConsoleLogger, RBX_PROGRAM_NAME, level);
} else {
expand_config_value(config.system_log, "$TMPDIR", config.system_tmp);
expand_config_value(config.system_log, "$PROGRAM_NAME", RBX_PROGRAM_NAME);
expand_config_value(config.system_log, "$USER", shared->username.c_str());
expand_config_value(config.system_log.value, "$TMPDIR", config.system_tmp);
expand_config_value(config.system_log.value, "$PROGRAM_NAME", RBX_PROGRAM_NAME);
expand_config_value(config.system_log.value, "$USER", shared->username.c_str());

utilities::logger::open(utilities::logger::eFileLogger,
config.system_log.value.c_str(), level);
Expand Down Expand Up @@ -301,13 +301,13 @@ namespace rubinius {
set_fsapi_path();
}

void Environment::expand_config_value(config::String& cvar,
void Environment::expand_config_value(std::string& cvar,
const char* var, const char* value)
{
size_t index = cvar.value.find(var);
size_t index = cvar.find(var);

if(index != std::string::npos) {
cvar.value.replace(index, strlen(var), value);
cvar.replace(index, strlen(var), value);
}
}

Expand Down Expand Up @@ -340,13 +340,13 @@ namespace rubinius {
}

void Environment::set_fsapi_path() {
expand_config_value(config.system_fsapi_path, "$TMPDIR", config.system_tmp);
expand_config_value(config.system_fsapi_path, "$PROGRAM_NAME", RBX_PROGRAM_NAME);
expand_config_value(config.system_fsapi_path, "$USER", shared->username.c_str());
expand_config_value(config.system_fsapi_path, "$PID", shared->pid.c_str());

shared->fsapi_path.assign(config.system_fsapi_path.value);

expand_config_value(shared->fsapi_path, "$TMPDIR", config.system_tmp);
expand_config_value(shared->fsapi_path, "$PROGRAM_NAME", RBX_PROGRAM_NAME);
expand_config_value(shared->fsapi_path, "$USER", shared->username.c_str());
expand_config_value(shared->fsapi_path, "$PID", shared->pid.c_str());

create_fsapi(state);
}

Expand Down
2 changes: 1 addition & 1 deletion vm/environment.hpp
Expand Up @@ -99,7 +99,7 @@ namespace rubinius {
void load_conf(std::string path);
void load_string(std::string str);
void run_file(std::string path);
void expand_config_value(config::String& cvar, const char* var, const char* value);
void expand_config_value(std::string& cvar, const char* var, const char* value);
void set_tmp_path();
void set_username();
void set_pid();
Expand Down
1 change: 1 addition & 0 deletions vm/shared_state.cpp
Expand Up @@ -239,6 +239,7 @@ namespace rubinius {
capi_constant_lock_.init();
internal_threads_->init();

env_->set_pid();
env_->set_fsapi_path();

env_->stop_logging(state);
Expand Down

0 comments on commit b580cd6

Please sign in to comment.