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 Date: Fri, 29 Apr 2005 11:23:49 -0400 From: Christopher Faylor To: cygwin AT cygwin DOT com Subject: Re: Help understanding process tree Message-ID: <20050429152349.GC10017@trixie.casa.cgf.cx> Reply-To: cygwin AT cygwin DOT com References: <4270F2F5 DOT 5010000 AT agilent DOT com> <20050428150258 DOT GB13295 AT trixie DOT casa DOT cgf DOT cx> <20050429072631 DOT GC3112 AT efn DOT org> <20050429150142 DOT GF7328 AT trixie DOT casa DOT cgf DOT cx> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20050429150142.GF7328@trixie.casa.cgf.cx> User-Agent: Mutt/1.5.8i On Fri, Apr 29, 2005 at 11:01:42AM -0400, Christopher Faylor wrote: >On Fri, Apr 29, 2005 at 12:26:32AM -0700, Yitzchak Scott-Thoennes wrote: >>On Thu, Apr 28, 2005 at 11:02:58AM -0400, Christopher Faylor wrote: >>> On Thu, Apr 28, 2005 at 07:28:05AM -0700, Earl Chew wrote: >>> >I'm working on a cygwin problem and have been looking at the Win32 >>> >process tree structure using Process Explorer from Sysinternals: >>> > >>> >http://www.sysinternals.com/ntw2k/freeware/procexp.shtml >>> > >>> >I'd like help understanding why Process Explorer shows cygwin >>> >child processes as orphans, but win32 child processes as children. >>> > >>> >How is this so? >>> > >>> >For example, if I start bash, then start cmd /c dir, I will see: >>> > >>> >bash >>> > bash >>> > cmd /c dir >>> > >>> >My reading of the code is that the 2nd bash is the fork-stub that is >>> >waiting for cmd to complete. >>> > >>> >Now, if I start sleep 30, I will see: >>> > >>> >bash >>> >sleep 30 >>> >>> Right. cmd is a non-cygwin program so it needs a cygwin stub to handle >>> being "execed". sleep is a cygwin program and does not require any >>> hand holding. >> >>Now go back and reread the sentence where he says "I'd like help >>understanding why..." :) > >exec is not a windows concept. There is no way for one program to pass >on the pid of another program. So, while cygwin does use windows pids, >when a process is execed, the new process is passed a handle to the original >process (to stop the original pid from being used), and the original process >exits. Since the original process disappears, I suppose that would make >the execed process look like an orphan. > >"a non-cygwin program...needs a cygwin stub to handle being execed" > >If the process being execed is a pure windows process, the original process >sticks around, waiting for handshaking with the new process which indicates >that the new process knows how to deal with being execed. Since that never >comes, the original process stays around until the new process exits and >you'll there will be no orphan. Sigh. I tried so hard to come up with a concise description and I still muffed it. "Since that never comes, the original process stays around until the new process exits and there will be no orphan." cgf -- 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/