X-Spam-Check-By: sourceware.org From: ericblake AT comcast DOT net (Eric Blake) To: Kaveh Goudarzi , cygwin AT cygwin DOT com Subject: Re: Truncated Environment Variables? - using Cygwin + GetEnvironmentStrings() WIN32 API Date: Sun, 30 Apr 2006 03:32:55 +0000 Message-Id: <043020060332.28083.44542FE70000653100006DB322007614380A050E040D0C079D0A@comcast.net> X-Mailer: AT&T Message Center Version 1 (Apr 11 2006) Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com > > I'm working on an app which attempts to get > the environment of running cygwin apps. It does this > by running the GetEnvironmentStrings() win32 api call > in the context of the running cygwin app (code injection). That is somewhat risky, as recent threads have discussed how windows update does a code injection that interferes with cygwin and deadlocks the processor into 100% utilization. > However the result that comes back as a truncated version of > the environment - only 4 values PATH, SYSTEMDRIVE, SYSTEMROOT, > WINDIR. Correct. That's all the more cygwin processes use of the Windows environment. Going through Windows is slow and limited, so cygwin uses its own environment, converting to Windows only at the last minute when spawning a non-cygwin process. > > I saw the article below which seems relevant but I > was confused because my understanding of it would mean that > the call using win32 api should fail when run under both cmd.exe > and bash.exe which is not the case. > > http://cygwin.com/ml/cygwin/2006-01/msg00938.html A cygwin process invoked directly from cmd.com (currently) does not go out of its way to clear the environment, but child processes of cygwin do not waste time propagating everything via the Windows environment. > > I would be most grateful if someone could tell me > why this might be happening and what possible alternative > paths I could follow. If you wanted to be more like Linux, you could implement something in the /proc virtual file system that enumerated the environment of a particular process; by asking cygwin what cygwin thinks the environment, and without thread injection, you would get a better answer than by asking Windows about the cygwin environment; plus, you will be isolated from any further implementation changes cygwin makes with its under-the-hood handling of the environ. Why do you need to know the environment of a running cygwin process, anyways? Perhaps explaining your need would allow us to come up with an alternative approach. > > PS. I've attached the output of "cygcheck -s -v -r > cygcheck.out" Actually, you attached a one line file with contents "cygcheck -s -v -r". -- Eric Blake -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/