Subject: | cygwin add Win32::Process::GetCurrentProcessID() (not $$) |
Attached patch bumps Win32::Process to 0.10
Added Win32::Process::GetCurrentProcessID(), because $$ != winpid on cygwin.
There's no way to get the windows pid of cygwin processes, needed for Win32::Process.
You could also get it via Win32::API (or another FFI) but there's none in libwin32, so I added this needed function it to Win32::Process.
Missing is a general cygwin pid => windows pid translator.
diff -bur libwin32-0.191.orig/Process/Changes perl-libwin32-0.191/Process/Changes
--- libwin32-0.191.orig/Process/Changes 2002-07-09 02:15:54.000000000 +0100
+++ perl-libwin32-0.191/Process/Changes 2005-02-06 18:51:35.456648200 +0100
@@ -1,5 +1,8 @@
Revision history for Perl extension Win32::Process.
+0.10 Sun Feb 6 18:50:44 2005
+ - add GetCurrentProcessID() for cygwin (by Reini Urban <rurban@x-ray.at>)
+
0.09 Fri Aug 17 16:11:58 2001
- allow opening an existing pid, like OpenProcess() (thanks to
Blair Zajac <blair@orcaware.com>)
diff -bur libwin32-0.191.orig/Process/Makefile.PL perl-libwin32-0.191/Process/Makefile.PL
diff -bur libwin32-0.191.orig/Process/Process.hpp perl-libwin32-0.191/Process/Process.hpp
diff -bur libwin32-0.191.orig/Process/Process.pm perl-libwin32-0.191/Process/Process.pm
--- libwin32-0.191.orig/Process/Process.pm 2002-07-09 02:15:54.000000000 +0100
+++ perl-libwin32-0.191/Process/Process.pm 2005-02-06 18:46:22.165788500 +0100
@@ -4,7 +4,7 @@
require DynaLoader;
@ISA = qw(Exporter DynaLoader);
-$VERSION = '0.09';
+$VERSION = '0.10';
# Items to export into callers namespace by default. Note: do not export
# names by default without a very good reason. Use EXPORT_OK instead.
@@ -159,6 +159,13 @@
Returns the Process ID.
+=item Win32::Process::GetCurrentProcessID()
+
+Returns the current process ID, which is the same as $$. But not on cygwin,
+where $$ is the cygwin-internal PID and not the windows PID.
+On cygwin GetCurrentProcessID() returns the windows PID as needed for all
+the Win32::Process functions.
+
=back
=head1 EXPORTS
diff -bur libwin32-0.191.orig/Process/Process.xs perl-libwin32-0.191/Process/Process.xs
--- libwin32-0.191.orig/Process/Process.xs 2002-07-09 02:15:54.000000000 +0100
+++ perl-libwin32-0.191/Process/Process.xs 2005-02-06 18:42:35.232645700 +0100
@@ -455,3 +445,11 @@
}
OUTPUT:
RETVAL
+
+DWORD
+GetCurrentProcessID()
+CODE:
+ RETVAL = GetCurrentProcessId();
+OUTPUT:
+ RETVAL
+
diff -bur libwin32-0.191.orig/Process/test.pl perl-libwin32-0.191/Process/test.pl
--- libwin32-0.191.orig/Process/test.pl 2002-07-09 02:15:54.000000000 +0100
+++ perl-libwin32-0.191/Process/test.pl 2005-02-06 18:43:26.372288800 +0100
@@ -30,7 +30,8 @@
# of the test code):
my $p;
-if (Win32::Process::Open($p, $$, 0)) {
+my $pid = $^O eq 'cygwin' ? Win32::Process::GetCurrentProcessID() : $$;
+if (Win32::Process::Open($p, $pid, 0)) {
ok(1);
ok($p->SetPriorityClass(HIGH_PRIORITY_CLASS))
} else {
Nur in perl-libwin32-0.191/Process: test.pl~.
diff -bur libwin32-0.191.orig/Process/typemap perl-libwin32-0.191/Process/typemap
--- libwin32-0.191.orig/Process/typemap 2002-07-09 02:15:54.000000000 +0100
+++ perl-libwin32-0.191/Process/typemap 2004-12-02 00:55:57.797179500 +0100
@@ -12,7 +12,7 @@
T_PTROBJ
if (sv_derived_from($arg, \"${Package}\")) {
IV tmp = SvIV((SV*)SvRV($arg));
- $var = ($type) tmp;
+ $var = ($type)(DWORD) tmp;
}
else
croak(\"$var is not of type ${Package}\")