From: Laurent Sansonetti Date: 2006-06-30T00:57:56+09:00 Subject: Re: [rubycore:04804] and darwin Hi Matz, On 6/29/06, Yukihiro Matsumoto wrote: > Hi, > > In message "Re: [rubycore:04804] and darwin" > on Tue, 27 Jun 2006 21:37:55 +0900, "Laurent Sansonetti" writes: > > |Disabling this piece of code in ruby.c fixes the problem: > | > |+ if (s + 1 == envspace.begin) { > |+ s = envspace.end; > |+ ruby_setenv("", NULL); /* duplicate environ vars */ > |+ } > | > |I did not investigated more, but is this change supposed to work with > |setproctitle-less systems? > > Yes. More precisely, it should work for the systems that > > * have no PSTAT_SETCMD > * nor setproctitle > * nor setenv/getenv > * and are not Win32 > > I am not sure how we can detect Darwin correctly. Any info? Strange that it does not work here. Almost (all?) BSD-based systems have setproctitle, except Darwin. Here the number of extra space characters is equal to the length of all environment variables (in environ). To detect Darwin you can check for __APPLE__. Isolating the piece of code in ruby.c between #if !defined(__APPLE__) fixed the problem. And I see that in process.c there is even a better check: #if defined(__APPLE__) && ( defined(__MACH__) || defined(__DARWIN__) ) && !defined(__MacOS_X__) #define __MacOS_X__ 1 #endif Laurent