| 1 | 304 | ▶ | use 5.008003; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 2 | 304 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | 304 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | package IPC::Run::Fused::POSIX; | ||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | 304 | our $VERSION = '1.000000'; | |||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | # ABSTRACT: Implementation of IPC::Run::Fused for POSIX-ish systems. | ||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | 304 | our $AUTHORITY = 'cpan:KENTNL'; # AUTHORITY | |||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | 304 | ▶ | use IO::Handle; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 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 | 304 | ▶ | use Exporter qw(import); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 40 | 304 | ▶ | use IPC::Run::Fused qw( _fail ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | 304 | our @EXPORT_OK = qw( run_fused ); | |||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | sub run_fused { ## no critic ( Subroutines::RequireArgUnpacking ) | ||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | 15450 | ▶ | my ( $read_handle, @params ) = ( \shift @_, @_ ); | ||||||||||||||||||||||||||
|
Subroutine
run_fused: called CC=11 SCAR=28.5
Pod
documented
| |||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | 15450 | my ( $reader, $writer ); | |||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | 15450 | ▶ | pipe $reader, $writer or _fail('Creating Pipe'); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | 15450 | ▶ | if ( my $pid = fork ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 53 | 15150 | ${$read_handle} = $reader; | |||||||||||||||||||||||||||
| 54 | 15150 | return $pid; | |||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | 300 | ▶ | open *STDOUT, '>>&=', $writer->fileno or _fail('Assigning to STDOUT'); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 58 | 300 | ▶ | open *STDERR, '>>&=', $writer->fileno or _fail('Assigning to STDERR'); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | 300 | ▶ | if ( ref $params[0] and 'CODE' eq ref $params[0] ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
ref $params[0] and "CODE" eq ref $params[0]
MC/DC50%1/2
ref $params[0] and "CODE" eq ref $params[0]
ref $params[0]
"CODE" eq ref $params[0]
Truth table66%2/3
A and B
A= ref $params[0]B= "CODE" eq ref $params[0]
| |||||||||||||||||||||||||||||
| 61 | 100 | $params[0]->(); | |||||||||||||||||||||||||||
| 62 | 100 | exit; | |||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||
| 64 | 200 | ▶ | if ( ref $params[0] and 'SCALAR' eq ref $params[0] ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
ref $params[0] and "SCALAR" eq ref $params[0]
MC/DC0%0/2
ref $params[0] and "SCALAR" eq ref $params[0]
ref $params[0]
"SCALAR" eq ref $params[0]
Truth table33%1/3
A and B
A= ref $params[0]B= "SCALAR" eq ref $params[0]
| |||||||||||||||||||||||||||||
| 65 | 0 | my $command = ${ $params[0] }; | |||||||||||||||||||||||||||
| 66 | 0 | ▶ | exec $command or _fail('<<exec command>> failed'); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 67 | 0 | exit; | |||||||||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||
| 70 | 200 | my $program = $params[0]; | |||||||||||||||||||||||||||
| 71 | ## no critic (ValuesAndExpressions::RequireInterpolationOfMetachars) | ||||||||||||||||||||||||||||
| 72 | 200 | ▶ | exec {$program} @params or _fail('<<exec {program} @argv>> failed'); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 73 | 0 | exit; | |||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||
| 76 | 304 | 1; | |||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||
| 78 | __END__ | ||||||||||||||||||||||||||||