#!perl -w
BEGIN {
chdir
't'
if
-d
't'
;
require
'./test.pl'
;
set_up_inc(
qw(../lib)
);
skip_all_if_miniperl(
"no dynamic loading on miniperl, no threads/attributes"
);
}
{
skip_all_without_config(
qw(useithreads d_getppid)
);
eval
'use threads; use threads::shared'
;
plan
tests
=> 3;
if
($@) {
fail(
"unable to load thread modules"
);
}
else
{
pass(
"thread modules loaded"
);
}
}
my
(
$pid
,
$ppid
) = ($$,
getppid
());
my
$pid2
: shared = 0;
my
$ppid2
: shared = 0;
new threads(
sub
{ (
$pid2
,
$ppid2
) = ($$,
getppid
()); } ) ->
join
();
my
$thread_version
=
qx[getconf GNU_LIBPTHREAD_VERSION 2>&1]
//
''
;
chomp
$thread_version
;
if
($^O =~ /^(?:gnukfreebsd|linux)$/ and
$thread_version
=~ /linuxthreads/ and
!(
$thread_version
=~ /linuxthreads-(.*)/ && $1 >= 0.11)) {
diag
"We're running under $^O with linuxthreads <$thread_version>"
;
isnt(
$pid
,
$pid2
,
"getpid() in a thread is different from the parent on this non-POSIX system"
);
isnt(
$ppid
,
$ppid2
,
"getppid() in a thread is different from the parent on this non-POSIX system"
);
}
else
{
is(
$pid
,
$pid2
,
'getpid() in a thread is the same as in the parent'
);
is(
$ppid
,
$ppid2
,
'getppid() in a thread is the same as in the parent'
);
}