Re: overriding builtins quirk
[p5sagit/p5-mst-13.2.git] / t / op / getpid.t
CommitLineData
4d76a344 1#!perl -w
2
3# Tests if $$ and getppid return consistent values across threads
4
5BEGIN {
6 chdir 't' if -d 't';
7 @INC = qw(../lib);
88faa3e1 8 require './test.pl';
4d76a344 9}
10
11use strict;
12use Config;
13
88faa3e1 14plan tests => 2;
15
4d76a344 16BEGIN {
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
27use threads;
28use threads::shared;
29
30my ($pid, $ppid) = ($$, getppid());
31my $pid2 : shared = 0;
32my $ppid2 : shared = 0;
33
34new threads( sub { ($pid2, $ppid2) = ($$, getppid()); } ) -> join();
35
88faa3e1 36is($pid, $pid2, 'pids');
37is($ppid, $ppid2, 'ppids');