This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Remove bad advice from perllocale.pod
[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
LW
4
5$| = 1;
ac58e20f 6print "1..8\n";
378cc40b 7
c07a80fd
PP
8open(PIPE, "|-") || (exec 'tr', 'YX', 'ko');
9print PIPE "Xk 1\n";
10print PIPE "oY 2\n";
378cc40b
LW
11close PIPE;
12
13if (open(PIPE, "-|")) {
14 while(<PIPE>) {
ac58e20f 15 s/^not //;
378cc40b
LW
16 print;
17 }
18}
19else {
ac58e20f
LW
20 print STDOUT "not ok 3\n";
21 exec 'echo', 'not ok 4';
378cc40b 22}
ac58e20f
LW
23
24pipe(READER,WRITER) || die "Can't open pipe";
25
26if ($pid = fork) {
27 close WRITER;
28 while(<READER>) {
29 s/^not //;
30 y/A-Z/a-z/;
31 print;
32 }
33}
34else {
35 die "Couldn't fork" unless defined $pid;
36 close READER;
37 print WRITER "not ok 5\n";
38 open(STDOUT,">&WRITER") || die "Can't dup WRITER to STDOUT";
39 close WRITER;
40 exec 'echo', 'not ok 6';
41}
42
43
44pipe(READER,WRITER) || die "Can't open pipe";
45close READER;
46
47$SIG{'PIPE'} = 'broken_pipe';
48
49sub broken_pipe {
50 print "ok 7\n";
51}
52
53print WRITER "not ok 7\n";
54close WRITER;
55
56print "ok 8\n";