line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
1
|
|
|
1
|
|
956
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
46
|
|
2
|
1
|
|
|
1
|
|
8
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
58
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
package Win32::Detached; |
5
|
|
|
|
|
|
|
BEGIN { |
6
|
1
|
|
|
1
|
|
31
|
$Win32::Detached::VERSION = '1.103080'; |
7
|
|
|
|
|
|
|
} |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
# ABSTRACT: daemonize perl scripts under windows, without a console window |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
|
12
|
1
|
|
|
1
|
|
418
|
use Win32; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
use Win32::Process; |
14
|
|
|
|
|
|
|
use Cwd; |
15
|
|
|
|
|
|
|
use English; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
check_args(); |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub skip_flag { '--no_detach' } |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub check_args { |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
if ( grep { $_ eq skip_flag() } @ARGV ) { |
26
|
|
|
|
|
|
|
@ARGV = grep { $_ ne skip_flag() } @ARGV; |
27
|
|
|
|
|
|
|
return; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
return if $COMPILING; |
31
|
|
|
|
|
|
|
return if $PROGRAM_NAME =~ m/release-pod-coverage/; |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
return detach(); |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub detach { |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
my @cmd_parts = ( $EXECUTABLE_NAME, $PROGRAM_NAME, @ARGV, skip_flag() ); |
40
|
|
|
|
|
|
|
@cmd_parts = map { tr/ // ? qq["$_"] : $_ } @cmd_parts; # check all components for spaces and wrap if necessary |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
# build command string |
43
|
|
|
|
|
|
|
my $command = join " ", @cmd_parts; |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
my $process; |
46
|
|
|
|
|
|
|
my @proc_params = ( |
47
|
|
|
|
|
|
|
\$process, |
48
|
|
|
|
|
|
|
$EXECUTABLE_NAME, |
49
|
|
|
|
|
|
|
$command, |
50
|
|
|
|
|
|
|
0, |
51
|
|
|
|
|
|
|
DETACHED_PROCESS, |
52
|
|
|
|
|
|
|
cwd |
53
|
|
|
|
|
|
|
); |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
Win32::Process::Create( @proc_params ) or die Win32::FormatMessage(Win32::GetLastError()); |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
exit; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
1; |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
__END__ |