Re: overriding builtins quirk
[p5sagit/p5-mst-13.2.git] / t / op / getpid.t
1 #!perl -w
2
3 # Tests if $$ and getppid return consistent values across threads
4
5 BEGIN {
6     chdir 't' if -d 't';
7     @INC = qw(../lib);
8     require './test.pl';
9 }
10
11 use strict;
12 use Config;
13
14 plan tests => 2;
15
16 BEGIN {
17     if (!$Config{useithreads}) {
18         print "1..0 # Skip: no ithreads\n";
19         exit;
20     }
21     if (!$Config{d_getppid}) {
22         print "1..0 # Skip: no getppid\n";
23         exit;
24     }
25 }
26
27 use threads;
28 use threads::shared;
29
30 my ($pid, $ppid) = ($$, getppid());
31 my $pid2 : shared = 0;
32 my $ppid2 : shared = 0;
33
34 new threads( sub { ($pid2, $ppid2) = ($$, getppid()); } ) -> join();
35
36 is($pid,  $pid2,  'pids');
37 is($ppid, $ppid2, 'ppids');