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/