From fcfa9ec19265847c32ac9a40f8fee979cccb6eb0 Mon Sep 17 00:00:00 2001 From: nobu Date: Sat, 3 Oct 2015 15:09:47 +0000 Subject: ruby-runner * template/ruby-runner.c.in: wrapper to set dynamic loading path environment variable. /bin/sh on Mac OS X 10.11 (El Capitan) clears DYLD_LIBRARY_PATH. it must: - do nothing even if current directory is not present - do not set other environment variables, e.g. PWD, SHLVL, etc - do not open other FDs, e.g. pipes for timer thread git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52008 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- template/ruby-runner.c.in | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 template/ruby-runner.c.in (limited to 'template') diff --git a/template/ruby-runner.c.in b/template/ruby-runner.c.in new file mode 100644 index 0000000000..56386a8d6f --- /dev/null +++ b/template/ruby-runner.c.in @@ -0,0 +1,27 @@ +#include +#include +#include + +#define BUILDDIR "@abs_top_builddir@" +#define LIBPATHENV "@LIBPATHENV@" + +int +main(int argc, char **argv) +{ + static const char builddir[] = BUILDDIR; + const char *libpath = getenv(LIBPATHENV); + if (libpath) { + size_t n = strlen(libpath); + char *e = malloc(sizeof(builddir)+n+1); + memcpy(e, builddir, sizeof(builddir)-1); + e[sizeof(builddir)-1] = '@PATH_SEPARATOR@'; + memcpy(e+sizeof(builddir), libpath, n+1); + libpath = e; + } + else { + libpath = builddir; + } + setenv(LIBPATHENV, libpath, 1); + execv(BUILDDIR"/@RUBY_BASE_NAME@", argv); + return -1; +} -- cgit v1.2.3