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: Tue, 17 May 2005 23:08:29 -0400 From: Christopher Faylor To: cygwin AT cygwin DOT com Subject: Re: problems in Perl process management Message-ID: <20050518030829.GA17056@trixie.casa.cgf.cx> Reply-To: cygwin AT cygwin DOT com References: <55E0A3E94323974F83CFC5AAB96F68B801419715 AT snnexc03 DOT in DOT ce DOT com DOT au> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <55E0A3E94323974F83CFC5AAB96F68B801419715@snnexc03.in.ce.com.au> User-Agent: Mutt/1.5.8i On Wed, May 18, 2005 at 01:01:48PM +1000, Sonam Chauhan wrote: >Reini: > >[Note, I'm no Cygwin expert, so please correct any misunderstandings.] > >> >>or fix it in this module XS. It's really easy with the cygwin provided >> >>translation functions. >> >> See http://sourceware.org/ml/cygwin/2005-02/msg00154.html >... >> > After all, Proc::ProcessTable misreports the PID and >> > PPID only under certain conditions -- this would indicate a complex >> issue in >> > Proc::ProcessTable XS code, right? >> >> No. Just the translation is needed, but one has to specify somehow which >> pid's he wants. The cygwin pid's or the winpid's. >> Both have their merits and usecases. > >Why are two usecases needed? The code that builds the process table >(returned by Proc::ProcessTable->table) should return the same PID and PPID >that 'ps' reports - no exceptions - right? > >I had a look in Proc::ProcessTable's .xs and os/cygwin.c. There seem to be a >problem with the process table data returned by this code in the >OS_get_table() function: > >This defines an internal Cygwin query to return process information: > cygwin_getinfo_types query = CW_GETPINFO_FULL; >This executes the query within a for loop: > p = (external_pinfo *) cygwin_internal (query, pid | CW_NEXTPID); > >From what I gather, the root problem is that for some processes (as >demonstrated by my testcase script), the CW_GETPINFO_FULL query returns: >1. Invalid PPIDs Only PPIDs for cygwin processes are returned. Everything else should be 0. Orphaned cygwin processes or processes started from the command line have a PPID of 1. >2. WINPID instead of Cygwin PID. A cygwin pid can actually be spread across two processes. You see this with "ps -W" if you do something like: bash -c "exec sleep 20" in one window and: ps -W in another window. ps -W will also not always properly report on execed processes in general. Since ps -W uses CW_GETPINFO_FULL, you can use that command to see what is going on. 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/