delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2009/01/15/21:00:54

X-Recipient: archive-cygwin AT delorie DOT com
X-SWARE-Spam-Status: No, hits=-0.6 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_LOW,RCVD_NUMERIC_HELO,SPF_HELO_PASS,SPF_PASS
X-Spam-Check-By: sourceware.org
To: cygwin AT cygwin DOT com
From: "Lenik" <len1 AT bodz DOT net>
Subject: Re: Bash doesn't launch the applications directly.
Date: Fri, 16 Jan 2009 09:59:49 +0800
Lines: 61
Message-ID: <gkopmr$573$1@ger.gmane.org>
References: <gkm1pc$717$1 AT ger DOT gmane DOT org> <496F34BB DOT 6080200 AT byu DOT net>
Mime-Version: 1.0
X-IsSubscribed: yes
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
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
Note-from-DJ: This may be spam


"Eric Blake" <ebb9 AT byu DOT net> 写入消息 news:496F34BB DOT 6080200 AT byu DOT net...
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> According to Lenik on 1/14/2009 5:59 PM:
>> Hi, all
>>
>> I noticed that when bash launches a program, for example win32
>> notepad.exe or cygwin sleep, it in fact launches another bash which
>> launches the final program,
>>
>> Any idea?
>
> Yes.  It's called forking (a concept that Windows does not have natively,
> but which cygwin does a LOT of work to emulate).  The way Unix apps
> (including bash) start another program is to first fork themselves, then
> in that fork, exec the target program.  The fork accounts for the second
> bash process.
>
> Depending on the nature of the called process, you might also see those
> additional processes stick around.  If the child is a cygwin process (like
> sleep), exec() is decently emulated, where the forked bash goes away and
> you are left with only one running sleep process.  But if it is a windows
How fast does the emulation implemented?

> process (like notepad), cygwin has to insert a shim process in between to
> handle signal handling in order to abort notepad if you type ctrl-c in
> bash, as well as collect the correct exit status.
Is there any option to disable the shim process?

I have tried to launch notepad in background:
  # calc &
In such situation, we won't ever press ctrl-c or ctrl-z, (maybe until fg 
%1), but there still got 2 bash processes. If I just want to send the launch 
signal to win32, and don't care what if user press ctrl-c in the bash.

I tried `cygstart `which notepad`', this did launch another bash, too (while 
it launches cygstart.exe and which.exe additionally). Though the cygstart 
and shim are then immediately terminated, but it cost the launching time.

>
> Ultimately, bash could be made faster by using posix_spawn() instead of
> fork(), for much of what it does.  However, that would require 1) an
> upstream patch to bash to use posix_spawn(), including a fallback
> implementation of posix_spawn on platforms that don't yet implement it
> (such an implementation is possible, since gnulib already provides one,
> but the upstream maintainer is hard to convince, and even if the patch
> existed, it has already missed the bash 4.0 cutoff), and 2) an
> implementation of posix_spawn() in cygwin that directly spawns processes
> using native Windows concepts (the bash fallback implementation of
> posix_spawn() would still end up using fork() under the hood, giving no
> speedups until we have a native version).  http://cygwin.com/acronyms/#PTC
>
Is it possible to make cygstart as a bash built-in? And thus will get 
another benefit that after cygstart.exe terminated, the parent-children 
relationship between the bash and notepad can be maintained.

Lenik 



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