This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
podcheck.t: skip make-rmg-checklist
[perl5.git] / t / op / getpid.t
CommitLineData
4d76a344
RGS
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
RGS
9}
10
11use strict;
12use Config;
13
14BEGIN {
77ba2250 15 skip_all_without_config(qw(useithreads d_getppid));
a7af648e 16 skip_all_if_miniperl("no dynamic loading on miniperl, no threads");
6765206c 17 eval 'use threads; use threads::shared';
3fc97137
RGS
18 plan tests => 3;
19 if ($@) {
20 fail("unable to load thread modules");
21 }
22 else {
23 pass("thread modules loaded");
24 }
4d76a344
RGS
25}
26
4d76a344
RGS
27my ($pid, $ppid) = ($$, getppid());
28my $pid2 : shared = 0;
29my $ppid2 : shared = 0;
30
31new threads( sub { ($pid2, $ppid2) = ($$, getppid()); } ) -> join();
32
88faa3e1
MS
33is($pid, $pid2, 'pids');
34is($ppid, $ppid2, 'ppids');