diff options
author | Rafael Garcia-Suarez <rgarciasuarez@gmail.com> | 2002-08-06 23:56:46 +0200 |
---|---|---|
committer | hv <hv@crypt.org> | 2002-08-29 11:44:00 +0000 |
commit | 4d76a3443f3312704ec3416fd425698e92a208cd (patch) | |
tree | 769fa92e2e9f3a46a171807a82b7d5fd7c623c0a /t/op/getpid.t | |
parent | 85cf7f2e6c0eee352cdc28bfa7e316574993c2ba (diff) | |
download | perl-4d76a3443f3312704ec3416fd425698e92a208cd.tar.gz |
posixify getppid on linux-multithread
Message-Id: <20020806215646.3f6852bb.rgarciasuarez@free.fr>
p4raw-id: //depot/perl@17798
Diffstat (limited to 't/op/getpid.t')
-rw-r--r-- | t/op/getpid.t | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/t/op/getpid.t b/t/op/getpid.t new file mode 100644 index 0000000000..dd06f006a6 --- /dev/null +++ b/t/op/getpid.t @@ -0,0 +1,35 @@ +#!perl -w + +# Tests if $$ and getppid return consistent values across threads + +BEGIN { + chdir 't' if -d 't'; + @INC = qw(../lib); +} + +use strict; +use Config; + +BEGIN { + if (!$Config{useithreads}) { + print "1..0 # Skip: no ithreads\n"; + exit; + } + if (!$Config{d_getppid}) { + print "1..0 # Skip: no getppid\n"; + exit; + } +} + +use threads; +use threads::shared; + +my ($pid, $ppid) = ($$, getppid()); +my $pid2 : shared = 0; +my $ppid2 : shared = 0; + +new threads( sub { ($pid2, $ppid2) = ($$, getppid()); } ) -> join(); + +print "1..2\n"; +print "not " if $pid != $pid2; print "ok 1 - pids\n"; +print "not " if $ppid != $ppid2; print "ok 2 - ppids\n"; |