blib/lib/IPC/Run/Fused/POSIX.pm untested

filter: Statementstmt 0.0% 0 / 44 Branchbran 0.0% 0 / 6 Conditioncond 0.0% 0 / 19 MC/DCmcdc n/a Subroutinesub 0.0% 0 / 7 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 77 SCAR 30.0
CC
4
Cov
0%
run_fused
20.0
BEGIN
2.0
BEGIN
2.0
CRAP 20.0
1 use 5.008003;
2 use strict;
3 use warnings;
4  
5 package IPC::Run::Fused::POSIX;
6  
7 our $VERSION = '1.000000';
8  
9 # ABSTRACT: Implementation of IPC::Run::Fused for POSIX-ish systems.
10  
11 our $AUTHORITY = 'cpan:KENTNL'; # AUTHORITY
12  
13 use IO::Handle;
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39 use Exporter qw(import);
40 use IPC::Run::Fused qw( _fail );
41  
42 our @EXPORT_OK = qw( run_fused );
43  
44 sub run_fused { ## no critic ( Subroutines::RequireArgUnpacking )
45  
46 my ( $read_handle, @params ) = ( \shift @_, @_ );
47  
48 my ( $reader, $writer );
49  
50 pipe $reader, $writer or _fail('Creating Pipe');
51  
52 if ( my $pid = fork ) {
53 ${$read_handle} = $reader;
54 return $pid;
55 }
56  
57 open *STDOUT, '>>&=', $writer->fileno or _fail('Assigning to STDOUT');
58 open *STDERR, '>>&=', $writer->fileno or _fail('Assigning to STDERR');
59  
60 if ( ref $params[0] and 'CODE' eq ref $params[0] ) {
61 $params[0]->();
62 exit;
63 }
64 if ( ref $params[0] and 'SCALAR' eq ref $params[0] ) {
65 my $command = ${ $params[0] };
66 exec $command or _fail('<<exec command>> failed');
67 exit;
68 }
69  
70 my $program = $params[0];
71 ## no critic (ValuesAndExpressions::RequireInterpolationOfMetachars)
72 exec {$program} @params or _fail('<<exec {program} @argv>> failed');
73 exit;
74 }
75  
76 1;
77  
78 __END__