perl 5.003_07: Configure
[p5sagit/p5-mst-13.2.git] / t / lib / io_pipe.t
CommitLineData
61f2b451 1#!./perl
2
3BEGIN {
4 @INC = '../lib';
5 require Config; import Config;
6 if ($Config{'extensions'} !~ /\bIO\b/ && $^O ne 'VMS') {
7 print "1..0\n";
8 exit 0;
9 }
10}
11
12use IO::Pipe;
13
14$| = 1;
15print "1..6\n";
16
17$pipe = new IO::Pipe;
18
19$pid = fork();
20
21if($pid)
22 {
23 $pipe->writer;
24 print $pipe "Xk 1\n";
25 print $pipe "oY 2\n";
26 $pipe->close;
27 wait;
28 }
29elsif(defined $pid)
30 {
31 $pipe->reader;
32 $stdin = bless \*STDIN, "IO::Handle";
33 $stdin->fdopen($pipe,"r");
34 exec 'tr', 'YX', 'ko';
35 }
36else
37 {
38 die;
39 }
40
41$pipe = new IO::Pipe;
42$pid = fork();
43
44if($pid)
45 {
46 $pipe->reader;
47 while(<$pipe>) {
48 s/^not //;
49 print;
50 }
51 $pipe->close;
52 wait;
53 }
54elsif(defined $pid)
55 {
56 $pipe->writer;
57
58 $stdout = bless \*STDOUT, "IO::Handle";
59 $stdout->fdopen($pipe,"w");
60 print STDOUT "not ok 3\n";
61 exec 'echo', 'not ok 4';
62 }
63else
64 {
65 die;
66 }
67
68$pipe = new IO::Pipe;
69$pipe->writer;
70
71$SIG{'PIPE'} = 'broken_pipe';
72
73sub broken_pipe {
74 print "ok 5\n";
75}
76
77print $pipe "not ok 5\n";
78$pipe->close;
79
80
81print "ok 6\n";
82