X-Recipient: archive-cygwin@delorie.com
X-Spam-Check-By: sourceware.org
Date: Tue, 3 May 2011 12:43:05 +0200
From: Corinna Vinschen <corinna-cygwin@cygwin.com>
To: cygwin@cygwin.com
Subject: Re: Two processes are always created while running cygwin program(bash, ls, etc) under windows 2003 x64 R2
Message-ID: <20110503104305.GF22745@calimero.vinschen.de>
Reply-To: cygwin@cygwin.com
Mail-Followup-To: cygwin@cygwin.com
References: <210B64CF6061D847B4FE2374C8F37C6959DC652E58@GVW1160EXB.americas.hpqcorp.net>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Disposition: inline
In-Reply-To: <210B64CF6061D847B4FE2374C8F37C6959DC652E58@GVW1160EXB.americas.hpqcorp.net>
User-Agent: Mutt/1.5.21 (2010-09-15)
Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm
Precedence: bulk
List-Id: <cygwin.cygwin.com>
List-Unsubscribe: <mailto:cygwin-unsubscribe-archive-cygwin=delorie.com@cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe@cygwin.com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin@cygwin.com>
List-Help: <mailto:cygwin-help@cygwin.com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner@cygwin.com
Mail-Followup-To: cygwin@cygwin.com
Delivered-To: mailing list cygwin@cygwin.com

On May  3 08:44, Oh, Choong-Hyun (HPSS-BSM) wrote:
> Dear all,
> 
> I found strange behavior of cywin application under windows 2003 x64 R2 version.
> When I run bash, it creates parent bash process and also child bash process as like followings;
> 
> 
> cmd.exe
>   +- bash.exe
>      +- bash.exe
> 
> services.exe
>   +- cygrunsvr.exe
>      +- cygrunsvr.exe
> 
> 
> But on Windows 2008 x64 R2 system, it create only one process as like followings;

I assume you mean non-64 bit here.

> cmd.exe
>   +- bash.exe
> 
> services.exe
>   +- cygrunsvr.exe
> 
> So I am wondering whether it is normal behavior of cygwin on Windows 2003 x64 R2 system or not.
> And also if so, what's a cause of this happening.

This happens if a Cygwin process (which is 32 bit and thus running in
the WOW64 environment) is called from a 64 bit Windows process.

On the older XP and 2003 64 bit systems, the first WOW64 processes
main thread started from a 64 bit process gets a stack address in the
range where usually the application itself resides.  This in turn
breaks Cygwin's fork.

Therefore a Cygwin process checks at process startup if it has been
started by a 64 bit parent process and if the stack address is in the
dangerous region.  If so, it re-spawns itself.  Since this second
process is started from another 32 bit process, its stack address is
useful again.  The intermediate process keeps in memory as long as the
re-spawned process runs.


Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Project Co-Leader          cygwin AT cygwin DOT com
Red Hat

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

