This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Fix C< hex('80') * 0x1000000 >
[perl5.git] / t / io / pipe.t
CommitLineData
378cc40b
LW
1#!./perl
2
79072805 3# $RCSfile: pipe.t,v $$Revision: 4.1 $$Date: 92/08/07 18:27:31 $
378cc40b 4
774d564b
PP
5BEGIN {
6 chdir 't' if -d 't';
7 @INC = '../lib';
8 require Config; import Config;
9 unless ($Config{'d_fork'}) {
10 print "1..0\n";
11 exit 0;
12 }
13}
14
378cc40b 15$| = 1;
ac58e20f 16print "1..8\n";
378cc40b 17
c07a80fd
PP
18open(PIPE, "|-") || (exec 'tr', 'YX', 'ko');
19print PIPE "Xk 1\n";
20print PIPE "oY 2\n";
378cc40b
LW
21close PIPE;
22
23if (open(PIPE, "-|")) {
24 while(<PIPE>) {
ac58e20f 25 s/^not //;
378cc40b
LW
26 print;
27 }
28}
29else {
ac58e20f
LW
30 print STDOUT "not ok 3\n";
31 exec 'echo', 'not ok 4';
378cc40b 32}
ac58e20f
LW
33
34pipe(READER,WRITER) || die "Can't open pipe";
35
36if ($pid = fork) {
37 close WRITER;
38 while(<READER>) {
39 s/^not //;
40 y/A-Z/a-z/;
41 print;
42 }
43}
44else {
45 die "Couldn't fork" unless defined $pid;
46 close READER;
47 print WRITER "not ok 5\n";
48 open(STDOUT,">&WRITER") || die "Can't dup WRITER to STDOUT";
49 close WRITER;
50 exec 'echo', 'not ok 6';
51}
52
53
54pipe(READER,WRITER) || die "Can't open pipe";
55close READER;
56
57$SIG{'PIPE'} = 'broken_pipe';
58
59sub broken_pipe {
60 print "ok 7\n";
61}
62
63print WRITER "not ok 7\n";
64close WRITER;
65
66print "ok 8\n";