File::Basename doesn't lazy load Carp right.
[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 }
9
10 use strict;
11 use Config;
12
13 BEGIN {
14     if (!$Config{useithreads}) {
15         print "1..0 # Skip: no ithreads\n";
16         exit;
17     }
18     if (!$Config{d_getppid}) {
19         print "1..0 # Skip: no getppid\n";
20         exit;
21     }
22 }
23
24 use threads;
25 use threads::shared;
26
27 my ($pid, $ppid) = ($$, getppid());
28 my $pid2 : shared = 0;
29 my $ppid2 : shared = 0;
30
31 new threads( sub { ($pid2, $ppid2) = ($$, getppid()); } ) -> join();
32
33 print "1..2\n";
34 print "not " if $pid  != $pid2;  print "ok 1 - pids\n";
35 print "not " if $ppid != $ppid2; print "ok 2 - ppids\n";