ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/cvsroot/Proc-FastSpawn/t/02_inherit.t
Revision: 1.2
Committed: Sun Apr 7 01:33:20 2013 UTC (13 years, 7 months ago) by root
Content type: application/x-troff
Branch: MAIN
CVS Tags: rel-1_1, rel-1_0, rel-1_2, HEAD
Changes since 1.1: +5 -1 lines
Log Message:
1.0

File Contents

# User Rev Content
1 root 1.1 BEGIN { $| = 1; print "1..6\n"; }
2    
3     use Proc::FastSpawn;
4    
5     print +(pipe R, W) ? "" : "not ", "ok 1\n";
6    
7     fd_inherit fileno R, 0;
8     fd_inherit fileno W, 1;
9    
10 root 1.2 # OpenBSD has a corrupted $^X when linking aaginst -lpthread
11     # so use Config instead.
12     use Config;
13    
14     my $pid = spawn $Config{perlpath}, [
15 root 1.1 qw(perl -e),
16     '
17     my $gr = (open my $r, "<&" . $ARGV[0]) ? 1 : 0;
18     my $gw = (open my $w, ">&" . $ARGV[1]) ? 1 : 0;
19    
20     syswrite $w, "$gr$gw";
21     ',
22     fileno R, fileno W
23     ];
24    
25     print $pid ? "" : "not ", "ok 2\n";
26    
27     close W;
28     my $grw = <R>;
29    
30     print +($pid == waitpid $pid, 0) ? "" : "not ", "ok 3\n";
31     print $? == 0x0000 ? "" : "not ", "ok 4\n";
32     print $grw eq "01" ? "" : "not ", "ok 5 # $grw\n";
33     print "ok 6\n";