| 1 | package Daemon::Daemonize; | ||||||||||||||||||||||||||||
| 2 | 10 | ▶ | BEGIN { | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | 10 | $Daemon::Daemonize::VERSION = '0.0052'; | |||||||||||||||||||||||||||
| 4 | } | ||||||||||||||||||||||||||||
| 5 | # ABSTRACT: An easy-to-use daemon(izing) toolkit | ||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | 10 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 10 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | 10 | ▶ | use Sub::Exporter::Util qw/ curry_method /; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | 10 | ▶ | use Sub::Exporter -setup => { exports => [ map { $_ => curry_method } qw/ | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 13 | daemonize | ||||||||||||||||||||||||||||
| 14 | superclose | ||||||||||||||||||||||||||||
| 15 | write_pidfile read_pidfile check_pidfile delete_pidfile | ||||||||||||||||||||||||||||
| 16 | does_process_exist can_signal_process check_port | ||||||||||||||||||||||||||||
| 17 | 10 | / ] }; | |||||||||||||||||||||||||||
| 18 | 10 | ▶ | use POSIX; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 19 | 10 | ▶ | use Carp; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 20 | 10 | ▶ | use Path::Class; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | 14 | ▶ | sub _fork_or_die { | ||||||||||||||||||||||||||
|
Subroutine
_fork_or_die: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||
| 23 | 14 | my $self = shift; | |||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | 14 | my $pid = fork; | |||||||||||||||||||||||||||
| 26 | 14 | ▶ | confess "Unable to fork" unless defined $pid; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 27 | 14 | return $pid; | |||||||||||||||||||||||||||
| 28 | } | ||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | 1 | ▶ | sub superclose { | ||||||||||||||||||||||||||
|
Subroutine
superclose: called CC=6 SCAR=19.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 31 | 1 | my $self = shift; | |||||||||||||||||||||||||||
| 32 | 1 | ▶ | my $from = shift || 0; | ||||||||||||||||||||||||||
|
Condition50%1/2
shift() || 0
MC/DC0%0/1
shift() || 0
shift()
Truth table50%1/2
A
A= shift()
| |||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | 1 | my $openmax = POSIX::sysconf( &POSIX::_SC_OPEN_MAX ); | |||||||||||||||||||||||||||
| 35 | 1 | ▶ | $openmax = 64 if ! defined( $openmax ) || $openmax < 0; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not defined $openmax or $openmax < 0
MC/DC0%0/2
not defined $openmax or $openmax < 0
not defined $openmax
$openmax < 0
Truth table33%1/3
not(A) or B
A= not defined $openmaxB= $openmax < 0
| |||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | 1 | ▶ | return unless $from < $openmax; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | 1 | POSIX::close( $_ ) foreach ($from .. $openmax - 1); | |||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | 18 | ▶ | sub daemonize { | ||||||||||||||||||||||||||
|
Subroutine
daemonize: called CC=27 SCAR=39.9
Pod
documented
| |||||||||||||||||||||||||||||
| 44 | 18 | my $self = shift; | |||||||||||||||||||||||||||
| 45 | 18 | my %options = @_; | |||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | { | ||||||||||||||||||||||||||||
| 48 | 18 | ▶ | if ( my $run = delete $options{run} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | 9 | ▶ | if ( -1 == $self->daemonize( %options, continue => 1 ) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 51 | # We're the parent, continue on... | ||||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||
| 53 | else { | ||||||||||||||||||||||||||||
| 54 | # We've daemonized... launch into the code we've been given... | ||||||||||||||||||||||||||||
| 55 | 1 | $run->(); | |||||||||||||||||||||||||||
| 56 | 1 | exit 0; | |||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | 4 | return; # Daemonization actually handled in call above... Abort, abort, pull-up! | |||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | 9 | ▶ | my $chdir = exists $options{chdir} ? $options{chdir} : '/'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 64 | 9 | ▶ | my $close = defined $options{close} ? $options{close} : 1; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||
| 66 | # Fork once to go into the background | ||||||||||||||||||||||||||||
| 67 | { | ||||||||||||||||||||||||||||
| 68 | 9 | ▶ | if ( my $pid = $self->_fork_or_die ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 69 | 4 | ▶ | return -1 if $options{continue}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 70 | 0 | exit 0; | |||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | # Create new session | ||||||||||||||||||||||||||||
| 75 | 5 | ▶ | (POSIX::setsid) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 76 | || confess "Cannot detach from controlling process"; | ||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||
| 78 | # Fork again to ensure that daemon never reacquires a control terminal | ||||||||||||||||||||||||||||
| 79 | 5 | ▶ | $self->_fork_or_die && exit 0; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||
| 81 | # Clear the file creation mask | ||||||||||||||||||||||||||||
| 82 | 1 | umask 0; | |||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||
| 84 | 1 | ▶ | if ( defined $chdir ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 85 | 1 | ▶ | chdir $chdir or confess "Unable to chdir to \"$chdir\": $!"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||
| 88 | 1 | ▶ | if ( $close eq 1 || $close eq '!std' ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$close eq 1 or $close eq "!std"
MC/DC0%0/2
$close eq 1 or $close eq "!std"
$close eq 1
$close eq "!std"
Truth table33%1/3
A or B
A= $close eq 1B= $close eq "!std"
| |||||||||||||||||||||||||||||
| 89 | # Close any open file descriptors | ||||||||||||||||||||||||||||
| 90 | 1 | ▶ | $self->superclose( $close eq '!std' ? 3 : 0 ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 91 | } | ||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||
| 93 | 1 | ▶ | my $stdout_file = $ENV{DAEMON_DAEMONIZE_STDOUT} || $options{stdout}; | ||||||||||||||||||||||||||
|
Condition33%1/3
$ENV{'DAEMON_DAEMONIZE_STDOUT'} || $options{'stdout'}
MC/DC0%0/2
$ENV{'DAEMON_DAEMONIZE_STDOUT'} || $options{'stdout'}
$ENV{'DAEMON_DAEMONIZE_STDOUT'}
$options{'stdout'}
Truth table33%1/3
A || B
A= $ENV{'DAEMON_DAEMONIZE_STDOUT'}B= $options{'stdout'}
| |||||||||||||||||||||||||||||
| 94 | 1 | ▶ | my $stderr_file = $ENV{DAEMON_DAEMONIZE_STDERR} || $options{stderr}; | ||||||||||||||||||||||||||
|
Condition33%1/3
$ENV{'DAEMON_DAEMONIZE_STDERR'} || $options{'stderr'}
MC/DC0%0/2
$ENV{'DAEMON_DAEMONIZE_STDERR'} || $options{'stderr'}
$ENV{'DAEMON_DAEMONIZE_STDERR'}
$options{'stderr'}
Truth table33%1/3
A || B
A= $ENV{'DAEMON_DAEMONIZE_STDERR'}B= $options{'stderr'}
| |||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||
| 96 | 1 | ▶ | if ( $close eq 1 || $close eq 'std' ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$close eq 1 or $close eq "std"
MC/DC0%0/2
$close eq 1 or $close eq "std"
$close eq 1
$close eq "std"
Truth table33%1/3
A or B
A= $close eq 1B= $close eq "std"
| |||||||||||||||||||||||||||||
| 97 | # Re-open STDIN, STDOUT, STDERR to /dev/null | ||||||||||||||||||||||||||||
| 98 | 1 | ▶ | open( STDIN, "+>/dev/null" ) or confess "Could not redirect STDIN to /dev/null"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||
| 100 | 1 | ▶ | unless ( $stdout_file ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 101 | 0 | ▶ | open( STDOUT, "+>&STDIN" ) or confess "Could not redirect STDOUT to /dev/null"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 102 | } | ||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||
| 104 | 1 | ▶ | unless ( $stderr_file ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 105 | 0 | ▶ | open( STDERR, "+>&STDIN" ) or confess "Could not redirect STDERR to /dev/null"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 106 | } | ||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||
| 108 | # Avoid 'stdin reopened for output' warning (taken from MooseX::Daemonize) | ||||||||||||||||||||||||||||
| 109 | 1 | local *_NIL; | |||||||||||||||||||||||||||
| 110 | 1 | open( _NIL, '/dev/null' ); | |||||||||||||||||||||||||||
| 111 | 1 | <_NIL> if 0; | |||||||||||||||||||||||||||
| 112 | } | ||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||
| 114 | 1 | ▶ | if ( $stdout_file ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 115 | 1 | ▶ | open STDOUT, ">>", $stdout_file or confess "Could not redirect STDOUT to $stdout_file : $!"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 116 | } | ||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||
| 118 | 1 | ▶ | if ( $stderr_file ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 119 | 1 | ▶ | open STDERR, ">>", $stderr_file or confess "Could not redirect STDERR to $stderr_file : $!"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 120 | } | ||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||
| 122 | 1 | return 1; | |||||||||||||||||||||||||||
| 123 | } | ||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||
| 125 | 29 | ▶ | sub _pidfile($) { | ||||||||||||||||||||||||||
|
Subroutine
_pidfile: called CC=3 SCAR=11.7
| |||||||||||||||||||||||||||||
| 126 | 29 | my $pidfile = shift; | |||||||||||||||||||||||||||
| 127 | 29 | ▶ | confess "No pidfile given" unless defined $pidfile; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 128 | 29 | ▶ | return Path::Class::File->new( ref $pidfile eq 'ARRAY' ? @$pidfile : "$pidfile" ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 129 | } | ||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||
| 132 | 16 | ▶ | sub read_pidfile { | ||||||||||||||||||||||||||
|
Subroutine
read_pidfile: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||
| 133 | 16 | my $self = shift; | |||||||||||||||||||||||||||
| 134 | 16 | my $pidfile = _pidfile shift; | |||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||
| 136 | 16 | ▶ | return unless -s $pidfile; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 137 | 13 | ▶ | return unless -f $pidfile && -r $pidfile; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
-f $pidfile and -r $pidfile
MC/DC50%1/2
-f $pidfile and -r $pidfile
-f $pidfile
-r $pidfile
Truth table66%2/3
A and B
A= -f $pidfileB= -r $pidfile
| |||||||||||||||||||||||||||||
| 138 | 11 | return scalar $pidfile->slurp( chomp => 1 ); | |||||||||||||||||||||||||||
| 139 | } | ||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||
| 142 | 9 | ▶ | sub check_pidfile { | ||||||||||||||||||||||||||
|
Subroutine
check_pidfile: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||
| 143 | 9 | my $self = shift; | |||||||||||||||||||||||||||
| 144 | 9 | my $pidfile = _pidfile shift; | |||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||
| 146 | 9 | my $pid = $self->read_pidfile( $pidfile ); | |||||||||||||||||||||||||||
| 147 | 9 | ▶ | return 0 unless $pid; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 148 | 7 | ▶ | return 0 unless $self->does_process_exist( $pid ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 149 | 6 | return $pid; | |||||||||||||||||||||||||||
| 150 | } | ||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||
| 153 | 3 | ▶ | sub write_pidfile { | ||||||||||||||||||||||||||
|
Subroutine
write_pidfile: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||
| 154 | 3 | my $self = shift; | |||||||||||||||||||||||||||
| 155 | 3 | my $pidfile = _pidfile shift; | |||||||||||||||||||||||||||
| 156 | 3 | ▶ | my $pid = shift || $$; | ||||||||||||||||||||||||||
|
Condition66%2/3
shift() || $$
MC/DC0%0/2
shift() || $$
shift()
$$
Truth table66%2/3
A || B
A= shift()B= $$
| |||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||
| 158 | 3 | my $fh = $pidfile->openw; | |||||||||||||||||||||||||||
| 159 | 3 | $fh->print( $pid . "\n" ); | |||||||||||||||||||||||||||
| 160 | 3 | $fh->close; | |||||||||||||||||||||||||||
| 161 | } | ||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||
| 164 | 1 | ▶ | sub delete_pidfile { | ||||||||||||||||||||||||||
|
Subroutine
delete_pidfile: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 165 | 1 | my $self = shift; | |||||||||||||||||||||||||||
| 166 | 1 | my $pidfile = _pidfile shift; | |||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||
| 168 | 1 | $pidfile->remove; | |||||||||||||||||||||||||||
| 169 | } | ||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||
| 172 | 7 | ▶ | sub does_process_exist { | ||||||||||||||||||||||||||
|
Subroutine
does_process_exist: called CC=6 SCAR=18.8
Pod
documented
| |||||||||||||||||||||||||||||
| 173 | 7 | my $self = shift; | |||||||||||||||||||||||||||
| 174 | 7 | my $pid = shift; | |||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||
| 176 | 7 | ▶ | croak "No pid given to check" unless $pid; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||
| 178 | 7 | ▶ | return 1 if kill 0, $pid; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 179 | 1 | my $errno = $!; | |||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||
| 181 | 1 | ▶ | if ( eval { require Errno } ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 182 | 1 | ▶ | return 1 if exists &Errno::EPERM && $errno == &Errno::EPERM; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
exists &Errno::EPERM and $errno == &Errno::EPERM
MC/DC0%0/2
exists &Errno::EPERM and $errno == &Errno::EPERM
exists &Errno::EPERM
$errno == &Errno::EPERM
Truth table33%1/3
A and B
A= exists &Errno::EPERMB= $errno == &Errno::EPERM
| |||||||||||||||||||||||||||||
| 183 | } | ||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||
| 185 | # So $errno == ESRCH, or we don't have Errno.pm, ... just going to assume non-existent | ||||||||||||||||||||||||||||
| 186 | 1 | return 0; | |||||||||||||||||||||||||||
| 187 | } | ||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||
| 190 | 0 | ▶ | sub can_signal_process { | ||||||||||||||||||||||||||
|
Subroutine
can_signal_process: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 191 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 192 | 0 | my $pid = shift; | |||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||
| 194 | 0 | ▶ | croak "No pid given to check" unless $pid; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||
| 196 | 0 | ▶ | return kill 0, $pid ? 1 : 0; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 197 | # So $! is ESRCH or EPERM or something else, so we can't signal/control it | ||||||||||||||||||||||||||||
| 198 | } | ||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||
| 201 | 0 | ▶ | sub check_port { | ||||||||||||||||||||||||||
|
Subroutine
check_port: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 202 | 0 | require IO::Socket::INET; | |||||||||||||||||||||||||||
| 203 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 204 | 0 | my $port = shift; | |||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||
| 206 | 0 | ▶ | croak "No port given to check" unless $port; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||
| 208 | 0 | my $socket = IO::Socket::INET->new( PeerAddr => 'localhost', PeerPort => $port, Proto => 'tcp' ); | |||||||||||||||||||||||||||
| 209 | 0 | ▶ | if ( $socket ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 210 | 0 | $socket->close; | |||||||||||||||||||||||||||
| 211 | 0 | return 1; | |||||||||||||||||||||||||||
| 212 | } | ||||||||||||||||||||||||||||
| 213 | 0 | return 0; | |||||||||||||||||||||||||||
| 214 | } | ||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||
| 217 | 10 | 1; | |||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||
| 219 | __END__ | ||||||||||||||||||||||||||||