1use strict; 2use Config qw(%Config); 3use Test; 4use Win32; 5 6my $fork_emulation = $Config{ccflags} =~ /PERL_IMPLICIT_SYS/; 7 8my $tests = $fork_emulation ? 4 : 2; 9plan tests => $tests; 10 11my $pid = $$+0; # make sure we don't copy any magic to $pid 12 13if ($^O eq "cygwin") { 14 skip(!defined &Cygwin::pid_to_winpid, 15 Cygwin::pid_to_winpid($pid), 16 Win32::GetCurrentProcessId()); 17} 18else { 19 ok($pid, Win32::GetCurrentProcessId()); 20} 21 22if ($fork_emulation) { 23 # This test relies on the implementation detail that the fork() emulation 24 # uses the negative value of the thread id as a pseudo process id. 25 if (my $child = fork) { 26 waitpid($child, 0); 27 exit 0; 28 } 29 ok(-$$, Win32::GetCurrentThreadId()); 30 31 # GetCurrentProcessId() should still return the real PID 32 ok($pid, Win32::GetCurrentProcessId()); 33 ok($$ != Win32::GetCurrentProcessId()); 34} 35else { 36 # here we just want to see something. 37 ok(Win32::GetCurrentThreadId() > 0); 38} 39