void launchCygwin(char** argValues) { std::string ARGV0 = *argValues; ++ argValues; size_t lastBackslash = ARGV0.rfind('\\'); std::string directoryPrefix; if (lastBackslash != std::string::npos) { directoryPrefix = ARGV0.substr(0, lastBackslash + 1); } std::string cygwinBin = findCygwinBin(); const char* oldPath = getenv("PATH"); if (oldPath == 0) { throw std::runtime_error("getenv(\"PATH\") implausibly returned null"); } // Windows doesn't support setenv but does support putenv. // We need cygwin1.dll to be on the PATH. std::string putenvArgument = std::string("PATH=") + oldPath + ";" + cygwinBin; if (putenv(putenvArgument.c_str()) == -1) { throw unix_exception(std::string("putenv(\"") + putenvArgument + "\") failed"); } checkReadableFile("Cygwin DLL", cygwinBin + "\\cygwin1.dll"); // Windows requires that we quote the arguments ourselves. typedef std::vector<std::string> Arguments; Arguments arguments; std::string program = directoryPrefix + "ruby-launcher.exe"; // We mustn't quote the program argument but we must quote argv[0]. arguments.push_back(quote(program)); // Make sure we invoke the Cygwin ruby, not any native version that might be ahead of it on the PATH. std::string rubyInterpreter = cygwinBin + "\\ruby.exe"; checkReadableFile("Cygwin Ruby", rubyInterpreter); arguments.push_back(quote(rubyInterpreter)); while (*argValues != 0) { const char* argument = *argValues; arguments.push_back(quote(argument)); ++ argValues; } typedef std::vector<char*> ArgValues; ArgValues childArgValues; for (Arguments::iterator it = arguments.begin(), en = arguments.end(); it != en; ++ it) { std::string& argument = *it; childArgValues.push_back(&argument[0]); } childArgValues.push_back(0); WindowsDllErrorModeChange windowsDllErrorModeChange; execv(program.c_str(), &childArgValues[0]); throw unix_exception(std::string("execv(\"") + program + "\", [" + join(", ", arguments) + "]) failed"); }
ss_explicit_k module(S const& moduleName, int mode = RTLD_NOW) : m_hmodule(load(moduleName, mode)) { # ifdef STLSOFT_CF_EXCEPTION_SUPPORT if(NULL == m_hmodule) { STLSOFT_THROW_X(unix_exception("Cannot load module", errno)); } # endif /* STLSOFT_CF_EXCEPTION_SUPPORT */ }