On Mon Feb 04 12:10:04 2013, WYANT wrote:
Show quoted text> On Sat Feb 02 17:33:23 2013, MITHUN wrote:
> > The WMI variance is un-useable on Cygwin. It fails to initialize with
> > the following message:
> >
> > "WMI broken: unable to get process object"
> >
> > This is because of the following line:
> >
> > $wmi and $proc = $wmi->Get( "Win32_Process='$$'" );
> >
> > where `$$` is the Cygwin pid and not a Windows pid. From my testing,
> > updating it to the
> > following seemed to resolve the issue.
> >
> > my $_testpid = ( $^O =~ /cygwin/i ) ? Cygwin::pid_to_winpid($$) :
> > $$;
> > $wmi and $proc = $wmi->Get( "Win32_Process='$_testpid'" );
> >
> > Thanks,
> > -- Mithun
>
> Unfortunately I do not have access to a Windows machine at this time
> (nor for a while, actually) so I am going to have to rely some on you to
> get this right.
>
> Before I dive in I have a couple questions:
>
> 1) The $$ variable appears several places in the code and tests other
> than the one you point out. Do all these need to be changed? If not, why
> not? I ask this because it looks to me like they do, and if they do not
> I would like to understand why not.
I think a `Cygwin::pid_to_winpid` (or vice-versa) conversion is required based on the context. In
most cases the module is interrogating Win32 and it probably should be using the Windows PID.
In the PT variant, it should probably leave `$$` as-is, since PT is cygwin aware and makes
distinctions between Cygwin/Windows PIDS ( or so I think - from my testing).
Show quoted text>
> 2) It appears that Cygwin Perl makes $$ the Cygwin process ID rather
> than the Windows one. Do you believe this means Win32::Process::Info
> should return Cygwin process IDs rather than Windows process IDs?
No. I think most people (including myself) use this primarily for Win32 processes.
Show quoted text>
> I'm pretty sure I can handle (1). (2) will be harder, but it may be the
> right thing to do given how the module works under other operating
> systems. On the other hand, if the NT variant works under Cygwin, any
> Cygwin users are used to getting Windows process IDs, and Cygwin process
> IDs will represent a change in behavior.
The NT variant does work under cygwin - and it provides Windows PIDs only. So yes, changing
this might surprise some folks unless NT gets priority over WMI on cygwin.
Since the primary usage for this is on MSWin32, the NT/WMI variants can possibly start returning
a CYGWINPID (?) for cygwin processes that have a different windows PID.
-- Mithun