This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Kludge for bareword handles
[perl5.git] / t / lib / posix.t
CommitLineData
a0d0e21e
LW
1#!./perl
2
3BEGIN {
4 chdir 't' if -d 't';
5 @INC = '../lib';
6 require Config; import Config;
fa6b8193 7 if ($^O ne 'VMS' and $Config{'extensions'} !~ /\bPOSIX\b/) {
c764b42b 8 print "1..0\n";
a0d0e21e
LW
9 exit 0;
10 }
11}
c07a80fd 12
a0d0e21e
LW
13use POSIX qw(fcntl_h signal_h limits_h _exit getcwd open read write);
14use strict subs;
15
c07a80fd
PP
16$| = 1;
17print "1..14\n";
a0d0e21e 18
c07a80fd 19$testfd = open("TEST", O_RDONLY, 0) and print "ok 1\n";
a0d0e21e 20read($testfd, $buffer, 9) if $testfd > 2;
c07a80fd
PP
21print $buffer eq "#!./perl\n" ? "ok 2\n" : "not ok 2\n";
22
23write(1,"ok 3\nnot ok 3\n", 5);
a0d0e21e
LW
24
25@fds = POSIX::pipe();
c07a80fd
PP
26print $fds[0] > $testfd ? "ok 4\n" : "not ok 4\n";
27CORE::open($reader = \*READER, "<&=".$fds[0]);
28CORE::open($writer = \*WRITER, ">&=".$fds[1]);
29print $writer "ok 5\n";
a0d0e21e
LW
30close $writer;
31print <$reader>;
32close $reader;
33
34$sigset = new POSIX::SigSet 1,3;
35delset $sigset 1;
c07a80fd
PP
36if (!ismember $sigset 1) { print "ok 6\n" }
37if (ismember $sigset 3) { print "ok 7\n" }
a0d0e21e
LW
38$mask = new POSIX::SigSet &SIGINT;
39$action = new POSIX::SigAction 'main::SigHUP', $mask, 0;
40sigaction(&SIGHUP, $action);
41$SIG{'INT'} = 'SigINT';
42kill 'HUP', $$;
43sleep 1;
c07a80fd 44print "ok 11\n";
a0d0e21e
LW
45
46sub SigHUP {
c07a80fd 47 print "ok 8\n";
a0d0e21e
LW
48 kill 'INT', $$;
49 sleep 2;
c07a80fd 50 print "ok 9\n";
a0d0e21e
LW
51}
52
53sub SigINT {
c07a80fd 54 print "ok 10\n";
a0d0e21e
LW
55}
56
c07a80fd 57print &_POSIX_OPEN_MAX > $fds[1] ? "ok 12\n" : "not ok 12\n";
a0d0e21e 58
c07a80fd 59print getcwd() =~ m#/t$# ? "ok 13\n" : "not ok 13\n";
a0d0e21e
LW
60
61# Pick up whether we're really able to dynamically load everything.
c07a80fd 62print &POSIX::acos(1.0) == 0.0 ? "ok 14\n" : "not ok 14\n";
a0d0e21e 63
c07a80fd 64$| = 0;
a0d0e21e
LW
65print '@#!*$@(!@#$';
66_exit(0);