Commit | Line | Data |
34f7f30d |
1 | use strict; |
2 | use Config qw(%Config); |
3 | use Test; |
4 | use Win32; |
5 | |
a7aed572 |
6 | my $fork_emulation = $Config{ccflags} =~ /PERL_IMPLICIT_SYS/; |
34f7f30d |
7 | |
a7aed572 |
8 | my $tests = $fork_emulation ? 4 : 2; |
9 | plan tests => $tests; |
10 | |
11 | my $pid = $$+0; # make sure we don't copy any magic to $pid |
12 | |
13 | if ($^O eq "cygwin") { |
14 | skip(!defined &Cygwin::pid_to_winpid, |
15 | Cygwin::pid_to_winpid($pid), |
16 | Win32::GetCurrentProcessId()); |
17 | } |
18 | else { |
19 | ok($pid, Win32::GetCurrentProcessId()); |
20 | } |
21 | |
22 | if ($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); |
c762d24b |
27 | exit 0; |
28 | } |
09ec0e73 |
29 | ok(-$$, Win32::GetCurrentThreadId()); |
a7aed572 |
30 | |
31 | # GetCurrentProcessId() should still return the real PID |
32 | ok($pid, Win32::GetCurrentProcessId()); |
33 | ok($$ != Win32::GetCurrentProcessId()); |
159fce98 |
34 | } |
35 | else { |
36 | # here we just want to see something. |
09ec0e73 |
37 | ok(Win32::GetCurrentThreadId() > 0); |
38 | } |