From 88f3b6efb4105b17998a22befdfd42244314935e Mon Sep 17 00:00:00 2001 From: ocean Date: Wed, 1 Feb 2006 13:27:47 +0000 Subject: [PATCH] * configure.in, hash.c (ruby_setenv): use setenv(3) and unsetenv(3) where they are supported. modifing environ variable seems to segfault solaris 10. [ruby-core:7276] [ruby-dev:28270] * ruby.c (set_arg0): if use setenv(3), environ space cannot be used for altering argv[0]. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9868 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 11 ++++++++++- configure.in | 2 +- hash.c | 4 +--- ruby.c | 11 +++++++++-- 4 files changed, 21 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index 14cb1eab7b..9ad8a169e5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +Wed Feb 1 22:01:47 2006 Hirokazu Yamamoto + + * configure.in, hash.c (ruby_setenv): use setenv(3) and unsetenv(3) + where they are supported. modifing environ variable seems to + segfault solaris 10. [ruby-core:7276] [ruby-dev:28270] + + * ruby.c (set_arg0): if use setenv(3), environ space cannot be used + for altering argv[0]. + Tue Jan 31 11:58:51 2006 Hidetoshi NAGAI * ext/tk/lib/multi-tk.rb: add MultiTkIp#eval and bg_eval. @@ -8,7 +17,7 @@ Tue Jan 31 11:58:51 2006 Hidetoshi NAGAI Tue Jan 31 00:08:22 2006 Hirokazu Yamamoto * ext/syck/rubyext.c (syck_resolver_transfer): workaround for SEGV. - ex: YAML.load("!map:B {}"). [ruby-core:7217] + ex: ruby -ryaml -e 'YAML.load("!map:B {}")' [ruby-core:7217] Sat Jan 28 07:49:30 2006 Hirokazu Yamamoto diff --git a/configure.in b/configure.in index 696e052022..05af353b29 100644 --- a/configure.in +++ b/configure.in @@ -506,7 +506,7 @@ AC_CHECK_FUNCS(fmod killpg wait4 waitpid fork spawnv syscall chroot fsync getcwd getpriority getrlimit setrlimit\ dlopen sigprocmask sigaction _setjmp vsnprintf snprintf\ setsid telldir seekdir fchmod mktime timegm cosh sinh tanh\ - setuid setgid daemon select_large_fdset) + setuid setgid daemon select_large_fdset setenv unsetenv) AC_ARG_ENABLE(setreuid, [ --enable-setreuid use setreuid()/setregid() according to need even if obsolete.], [use_setreuid=$enableval]) diff --git a/hash.c b/hash.c index a0af0fc5ce..53a0001318 100644 --- a/hash.c +++ b/hash.c @@ -196,8 +196,6 @@ rb_hash_foreach(VALUE hash, int (*func)(ANYARGS), VALUE farg) rb_ensure(hash_foreach_call, (VALUE)&arg, hash_foreach_ensure, hash); } -static VALUE hash_alloc(VALUE); - static VALUE hash_alloc(VALUE klass) { @@ -1690,7 +1688,7 @@ ruby_setenv(const char *name, const char *value) * RTL's environ global variable directly yet. */ SetEnvironmentVariable(name,value); -#elif defined __CYGWIN__ +#elif defined(HAVE_SETENV) && defined(HAVE_UNSETENV) #undef setenv #undef unsetenv if (value) diff --git a/ruby.c b/ruby.c index 353040f89d..338631d186 100644 --- a/ruby.c +++ b/ruby.c @@ -987,7 +987,14 @@ VALUE rb_progname; VALUE rb_argv; VALUE rb_argv0; -#if !defined(PSTAT_SETCMD) && !defined(HAVE_SETPROCTITLE) && !defined(DOSISH) +#if defined(PSTAT_SETCMD) || defined(HAVE_SETPROCTITLE) +#elif defined(_WIN32) +#elif defined(HAVE_SETENV) && defined(HAVE_UNSETENV) +#else +#define USE_ENVSPACE_FOR_ARG0 +#endif + +#ifdef USE_ENVSPACE_FOR_ARG0 static struct { char *begin, *end; } envspace; @@ -1061,7 +1068,7 @@ set_arg0(VALUE val, ID id) break; } } -#ifndef DOSISH +#if defined(USE_ENVSPACE_FOR_ARG0) if (s + 1 == envspace.begin) { s = envspace.end; ruby_setenv("", NULL); /* duplicate environ vars */