| 1 | package Mojolicious::Plugin::Minion::Workers; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 1 | ▶ | use Mojo::Base 'Mojolicious::Plugin::Minion'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 1 | our $VERSION = '0.9095';# as to Minion version/10+<child minor> | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 1 | has minion => undef, weak=>1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 1 | has qw(conf); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 0 | ▶ | sub register { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
register: not called CC=16 SCAR=56.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 0 | my ($self, $app, $conf) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 0 | my $workers = delete $conf->{workers}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 0 | my $manage = delete $conf->{manage}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 0 | ▶ | my $tasks = delete $conf->{tasks} || {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
delete $conf->{'tasks'} || {}
MC/DC0%0/1
delete $conf->{'tasks'} || {}
delete $conf->{'tasks'}
Truth table0%0/2
A
A= delete $conf->{'tasks'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 0 | my $helper = $app->renderer->get_helper('minion'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 0 | my @backend = keys %$conf; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | require Carp | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 0 | ▶ | and Carp::croak("Too many config args for Mojolicious::Plugin::Minion") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/8
@backend > 1 && !$helper && (require Carp && Carp::croak('Too many config args for Mojolicious::Plugin::Minion'))
@backend > 1 and not $helper
require Carp and Carp::croak("Too many config args for Mojolicious::Plugin::Minion")
MC/DC0%0/3
@backend > 1 && !$helper && (require Carp && Carp::croak('Too many config args for Mojolicious::Plugin::Minion'))
@backend > 1
not $helper
require Carp
Truth table0%0/4
A and not(B) && C
A= @backend > 1B= not $helperC= require Carp
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | if @backend > 1 && !$helper; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | $conf->{ $backend[0] } = $conf->{ $backend[0] }->($app) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 0 | ▶ | if $backend[0] && ref($conf->{ $backend[0] }) eq 'CODE'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$backend[0] and ref $$conf{$backend[0]} eq "CODE"
MC/DC0%0/2
$backend[0] and ref $$conf{$backend[0]} eq "CODE"
$backend[0]
ref $$conf{$backend[0]} eq "CODE"
Truth table0%0/3
A and B
A= $backend[0]B= ref $$conf{$backend[0]} eq "CODE"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 0 | ▶ | $self->SUPER::register($app, $conf) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$backend[0] and not $helper
MC/DC0%0/2
$backend[0] and not $helper
$backend[0]
not $helper
Truth table0%0/3
A and not(B)
A= $backend[0]B= not $helper
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | if $backend[0] && !$helper; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 0 | $self->minion($app->minion); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | $self->conf({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | %$conf, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | workers => $workers, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | is_manage => !$ARGV[0] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | || $ARGV[0] eq 'daemon' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | || $ARGV[0] eq 'prefork', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | is_prefork => $ENV{HYPNOTOAD_APP} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 0 | ▶ | || ($ARGV[0] && $ARGV[0] eq 'prefork'), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/12
!$ARGV[0] || $ARGV[0] eq 'daemon' || $ARGV[0] eq 'prefork'
not $ARGV[0] or $ARGV[0] eq "daemon"
$ENV{'HYPNOTOAD_APP'} || $ARGV[0] && $ARGV[0] eq 'prefork'
$ARGV[0] and $ARGV[0] eq "prefork"
MC/DC0%0/3
!$ARGV[0] || $ARGV[0] eq 'daemon' || $ARGV[0] eq 'prefork'
not $ARGV[0]
$ARGV[0] eq "daemon"
$ARGV[0] eq 'prefork'
MC/DC0%0/3
$ENV{'HYPNOTOAD_APP'} || $ARGV[0] && $ARGV[0] eq 'prefork'
$ENV{'HYPNOTOAD_APP'}
$ARGV[0]
$ARGV[0] eq "prefork"
Truth table0%0/4
not(A) or B || C
A= not $ARGV[0]B= $ARGV[0] eq "daemon"C= $ARGV[0] eq 'prefork'
Truth table0%0/4
A || B and C
A= $ENV{'HYPNOTOAD_APP'}B= $ARGV[0]C= $ARGV[0] eq "prefork"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 0 | ▶ | $app->minion->attr('workers'=> sub { $self }, weak=>1); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 0 | ▶ | while (my ($name, $sub) = each %$tasks) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 0 | $app->log->debug(sprintf("Applied Minion task [%s] in [%s] from config", $name, $app->minion->add_task($name => $sub))); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | $self->manage() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 0 | ▶ | and $self->conf->{is_manage} = 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/5
$manage && ($self->manage && ($self->conf->{'is_manage'} = 0))
$self->manage and $self->conf->{"is_manage"} = 0
MC/DC0%0/2
$manage && ($self->manage && ($self->conf->{'is_manage'} = 0))
$manage
$self->manage
Truth table0%0/3
A && B
A= $manageB= $self->manage
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | if $manage; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 0 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 0 | ▶ | sub manage { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
manage: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 0 | my ($self, $workers) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 0 | my $conf = $self->conf; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | return | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 0 | ▶ | unless $conf->{is_manage}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | $workers ||= $conf->{workers} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 0 | ▶ | or return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$workers ||= $conf->{"workers"}
MC/DC0%0/2
$workers ||= $conf->{"workers"}
$workers
$conf->{"workers"}
Truth table0%0/3
A ||= B
A= $workersB= $conf->{"workers"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 0 | my $minion = $self->minion; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 0 | ▶ | if ($conf->{is_prefork}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 0 | $self->prefork; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 0 | $self->subprocess; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 0 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | # Cases: hypnotoad script/app.pl | perl script/app.pl prefork | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 0 | ▶ | sub prefork { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
prefork: not called CC=7 SCAR=40.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | # case hot deploy and kill -USR2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | return | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | #~ if $hypnotoad_pid && !$ENV{HYPNOTOAD_STOP}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 0 | ▶ | if $ENV{HYPNOTOAD_PID} && !$ENV{HYPNOTOAD_STOP}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$ENV{"HYPNOTOAD_PID"} and not $ENV{"HYPNOTOAD_STOP"}
MC/DC0%0/2
$ENV{"HYPNOTOAD_PID"} and not $ENV{"HYPNOTOAD_STOP"}
$ENV{"HYPNOTOAD_PID"}
not $ENV{"HYPNOTOAD_STOP"}
Truth table0%0/3
A and not(B)
A= $ENV{"HYPNOTOAD_PID"}B= not $ENV{"HYPNOTOAD_STOP"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 0 | $self->kill_workers; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 0 | ▶ | return if $ENV{HYPNOTOAD_STOP}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 0 | my $workers = $self->conf->{workers}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 0 | ▶ | while ($workers--) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 0 | ▶ | defined(my $pid = fork()) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | || die "Can't fork: $!"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 0 | ▶ | next if $pid; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 0 | detach(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 0 | $self->worker_run; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 0 | CORE::exit(0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | # Cases: morbo script/app.pl | perl script/app.pl daemon | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 0 | ▶ | sub subprocess { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
subprocess: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 0 | $self->kill_workers; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | # subprocess allow run/restart worker later inside app worker | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 0 | my $subprocess = Mojo::IOLoop::Subprocess->new(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | $subprocess->run( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 0 | ▶ | sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 0 | my $subprocess = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 0 | $self->worker_run; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 0 | return $$; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 0 | ▶ | sub {1} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 0 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | # Dont $subprocess->ioloop->start here! | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 0 | ▶ | sub worker_run { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
worker_run: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 0 | my $minion = $self->minion; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 0 | $ENV{MINION_PID} = $$; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 0 | $0 = "$0 minion worker"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 0 | $minion->app->log->info("Minion worker (pid $$) was starting"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 0 | $minion->worker->run; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 0 | ▶ | sub kill_workers { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
kill_workers: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 0 | my ($self, $workers) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 0 | my $minion = $self->minion; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 0 | ▶ | $workers ||= $minion->backend->list_workers(0,1000)->{workers}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$workers ||= $minion->backend->list_workers(0, 1000)->{"workers"}
MC/DC0%0/2
$workers ||= $minion->backend->list_workers(0, 1000)->{"workers"}
$workers
$minion->backend->list_workers(0, 1000)->{"workers"}
Truth table0%0/3
A ||= B
A= $workersB= $minion->backend->list_workers(0, 1000)->{"workers"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | kill 'QUIT', $_->{pid} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | and $minion->app->log->info("Minion worker (pid $_->{pid}) was stopped") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 0 | ▶ | for @$workers; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 0 | ▶ | sub detach { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
detach: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | #~ chdir("/") || die "can't chdir to /: $!"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | #~ defined(my $pid = fork()) || die "can't fork: $!"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | #~ return 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | #~ if $pid; # parent | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | #~ require POSIX; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | #~ (POSIX::setsid() != -1) || die "Can't start a new session: $!"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 0 | ▶ | open(STDIN, "< /dev/null") || die "Can't read /dev/null: $!"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 0 | ▶ | open(STDOUT, "> /dev/null") || die "Can't write to /dev/null: $!"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 0 | ▶ | open(STDERR, ">&STDOUT") || die "Can't dup stdout: $!"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | #~ return $$; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||