* 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
This commit is contained in:
ocean 2006-02-01 13:27:47 +00:00
parent 598451429c
commit 88f3b6efb4
4 changed files with 21 additions and 7 deletions

View File

@ -1,3 +1,12 @@
Wed Feb 1 22:01:47 2006 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
* 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 <nagai@ai.kyutech.ac.jp> Tue Jan 31 11:58:51 2006 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
* ext/tk/lib/multi-tk.rb: add MultiTkIp#eval and bg_eval. * 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 <nagai@ai.kyutech.ac.jp>
Tue Jan 31 00:08:22 2006 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp> Tue Jan 31 00:08:22 2006 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
* ext/syck/rubyext.c (syck_resolver_transfer): workaround for SEGV. * 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 <ocean@m2.ccsnet.ne.jp> Sat Jan 28 07:49:30 2006 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>

View File

@ -506,7 +506,7 @@ AC_CHECK_FUNCS(fmod killpg wait4 waitpid fork spawnv syscall chroot fsync getcwd
getpriority getrlimit setrlimit\ getpriority getrlimit setrlimit\
dlopen sigprocmask sigaction _setjmp vsnprintf snprintf\ dlopen sigprocmask sigaction _setjmp vsnprintf snprintf\
setsid telldir seekdir fchmod mktime timegm cosh sinh tanh\ 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, AC_ARG_ENABLE(setreuid,
[ --enable-setreuid use setreuid()/setregid() according to need even if obsolete.], [ --enable-setreuid use setreuid()/setregid() according to need even if obsolete.],
[use_setreuid=$enableval]) [use_setreuid=$enableval])

4
hash.c
View File

@ -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); rb_ensure(hash_foreach_call, (VALUE)&arg, hash_foreach_ensure, hash);
} }
static VALUE hash_alloc(VALUE);
static VALUE static VALUE
hash_alloc(VALUE klass) hash_alloc(VALUE klass)
{ {
@ -1690,7 +1688,7 @@ ruby_setenv(const char *name, const char *value)
* RTL's environ global variable directly yet. * RTL's environ global variable directly yet.
*/ */
SetEnvironmentVariable(name,value); SetEnvironmentVariable(name,value);
#elif defined __CYGWIN__ #elif defined(HAVE_SETENV) && defined(HAVE_UNSETENV)
#undef setenv #undef setenv
#undef unsetenv #undef unsetenv
if (value) if (value)

11
ruby.c
View File

@ -987,7 +987,14 @@ VALUE rb_progname;
VALUE rb_argv; VALUE rb_argv;
VALUE rb_argv0; 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 { static struct {
char *begin, *end; char *begin, *end;
} envspace; } envspace;
@ -1061,7 +1068,7 @@ set_arg0(VALUE val, ID id)
break; break;
} }
} }
#ifndef DOSISH #if defined(USE_ENVSPACE_FOR_ARG0)
if (s + 1 == envspace.begin) { if (s + 1 == envspace.begin) {
s = envspace.end; s = envspace.end;
ruby_setenv("", NULL); /* duplicate environ vars */ ruby_setenv("", NULL); /* duplicate environ vars */