delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2006/01/19/15:07:30

X-Spam-Check-By: sourceware.org
Message-ID: <43CFF14E.E81BA7D0@dessent.net>
Date: Thu, 19 Jan 2006 12:06:38 -0800
From: Brian Dessent <brian AT dessent DOT net>
MIME-Version: 1.0
To: cygwin AT cygwin DOT com
Subject: Re: problem with run command and the environment
References: <20060119195323 DOT 55297 DOT qmail AT web35606 DOT mail DOT mud DOT yahoo DOT com>
X-IsSubscribed: yes
Reply-To: cygwin AT cygwin DOT com
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

Jeff Hardy wrote:

> Is this fact useful to the discussion? The run.exe
> executable that shows a limited view of the
> environment under the latest cygwin is exactly the
> same executable that runs on the older version of
> cygwin that I have that does NOT exhibit the same
> pathological behavior of displaying the limited
> environment. The same run.exe binary behaves
> differently on two different cygwins. On the older
> cygwin it displays the full environment and on the
> newer cygwin, it displays a severely limited view of
> the environment.

The internal behavior changed in Cygwin, which is why you see the
difference with the same run binary.  But that doesn't mean it's not
run's fault -- just as if you relied on undefined behavior in a program
and the compiler changed how it internally performed some optimization,
crashing your (broken) code.

Similarly, run is a Cygwin program but it directly calls CreateProcess. 
This puts it in the same rough footing as if a program opened a file
with CreateFile and then tried to pass that handle to Cygwin functions. 
In both cases the program is violating the abstraction levels -- Cygwin
apps should use the standard posix API (such as fork/exec).  Calling the
win32 API directly goes behind Cygwin's back and can cause all manor of
issues.

In the case of run it's necessary to call CreateProcess for the
functionality required, but this also means that it has to be careful to
do so in a way that is compatible with Cygwin -- in this case syncing
the environment first.

Brian

--
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/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019