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