From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10036 invoked from network); 21 Jul 2000 11:57:03 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 21 Jul 2000 11:57:03 -0000 Received: (qmail 23556 invoked by alias); 21 Jul 2000 11:56:50 -0000 Mailing-List: contact zsh-workers-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 12338 Received: (qmail 23549 invoked from network); 21 Jul 2000 11:56:49 -0000 X-Envelope-Sender-Is: Andrej.Borsenkow@mow.siemens.ru (at relayer goliath.siemens.de) From: "Andrej Borsenkow" To: "ZSH workers mailing list" Subject: Cygwin: environ problem Date: Fri, 21 Jul 2000 15:56:45 +0400 Message-ID: <000101bff30a$be2cc1d0$21c9ca95@mow.siemens.ru> MIME-Version: 1.0 Content-Type: text/plain; charset="koi8-r" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2911.0) Importance: Normal X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400 Tests for dynamic loading choke almost immediately. The reason is static libc and environ variable. It is contained in libc.a that is statically linked so every DLL gets it's own copy. BUT it looks, that exactly in case of Cygwin this test does not matter. If I understand correctly, what happens: - every DLL has control block, that contains pointer to "environ" for this DLL; this is of type 'char ***' intialised to point to "extern char **environ", that is a local varible: "user_data->envp = &environ". - main program has __cygwin_environ that points to actual "true" environment - every time environment changes (via setenv()/putnev()) and, of course, when loading DLL, cygwin updates local environ to point to __cygwin_environ, like "*(user_data->envp) = __cygwin_environ" In other words, every copy of environ is forced to point to the same location, even if addresses of variables itself are different. This implies that direct manipulation of environ is not possible (or, better said, make no sense). Zsh does exactly this - it directly assigns pointer to new environment block in createparamtable(). This needs to be fixed for Cygwin. It just occured to me, that it may be one reason for these misterious cores on Cygwin. It looks, like libc.a is actually nothing more than stub library for cygwin.dll. That is, we can ignore the above test on Cygwin. We _could_try_ to directly manipulate __cygwin_environ, but I do not like it - who knows, where and how it is used. BTW comments imply, that DLLs should actually refer to __cygwin_environ :-) -andrej Have a nice DOS! B >>